[R] Am I misunderstanding the ifelse construction?

Julien Barnier jbarnier at ens-lsh.fr
Tue Sep 25 10:18:39 CEST 2007


Hi,

> An I misunderstanding how to use the ifelse construct? And in that
> case, how should I go about doing this in a different way?

The ifelse function only apply to a single test passed as first
argument, and the second and third arguments are the value returned,
and thus should not be an R instruction like «gc_content <-
-gc_content».

Maybe you could try the following :

dataframe$numdir <- 1
dataframe$numdir[dataframe$dir=="-"] <- -1
d <- dataframe$gc_content * dataframe$numdir

HTH,

Julien

-- 
Julien Barnier
Groupe de recherche sur la socialisation
ENS-LSH - Lyon, France



More information about the R-help mailing list