[R] (no subject)
andy_liaw at merck.com
Wed Aug 11 17:22:05 CEST 2004
newVar <- ifelse(group == 1 & diagnosis == 1, 'positive', 'negative')
[You might want to coerce that to a factor if you wish.]
> From: Shaw, Philip (NIH/NIMH)
> A very simple question (from a R novice)
> How do I create a new variable within R. I have two existing
> variables (eg
> group number 1,2,3 and diagnosis 1,2,3). How would I create
> a new variable
> in which those in group1 with diagnosis 1 are assigned
> 'positive' and the
> remainder are 'negative'??
> Many thanks- and sorry it's so simple!
> [[alternative HTML version deleted]]
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide!
More information about the R-help