On Sep 21, 2010, at 2:47 PM, kurt_h...@nps.gov wrote: > All > Is there a script in R equivalent to the "if then" transforms one can > perform in Systat? For example, I want to create a "Treatment" column > coded either 1 or 2 for twelve field sites in a large data set. Ideally, > I'd be able to tell R to code sites a-f as 1 and sites g-l as 2. > Cheers > Kurt
Something along the lines of: Treatment <- ifelse(sites %in% c("a", "b", "c", "d", "e", "f"), 1, 2) should work. See ?"%in%" and ?ifelse HTH, Marc Schwartz ______________________________________________ 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.