[R] simple if statement

Ken Knoblauch kknoblauch at free.fr
Fri Apr 7 09:05:58 CEST 2006


How about the following, if you really want characters or just leave as 
factor

i <- round(runif(10, 1, 4))
  years <- as.character(factor(i, labels = c("Freshman", "Sophomore", 
"Junior", "Senior")))

HTH,

ken




More information about the R-help mailing list