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