[R] ifelse help
r at jp.pair.com
Wed Jul 11 02:26:07 CEST 2012
I'm sure this is easy, but I'm new to R and can't find any example of
Here's what I'm trying to do in pseudo-code.
data$newvar <- ifelse(data$oldvar1 == 8, 1,data$oldvar2)
In other words, if the existing variable equals 8, then the new
variable should equal 1, otherwise the new variable should equal the
value of another existing variable.
I've tried to follow the examples given on the web and in the R
manuals, and each time I get errors or unexpected values.
More information about the R-help