On 16/01/2014 8:46 AM, ONKELINX, Thierry wrote:
You want
y <- ifelse(x == 'a', 1, 2)
or use if, rather than ifelse, i.e.
if (x == 'a') {
y <- 1
} else {
y <- 2
}
ifelse() is mainly used when you want to work with whole vectors of
decisions, e.g.
x <- 1:10
ifelse(x > 5, 1, 0)
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.