[R] (no subject)

Liaw, Andy andy_liaw at merck.com
Wed Aug 11 17:22:05 CEST 2004


Something like:

newVar <- ifelse(group == 1 & diagnosis == 1, 'positive', 'negative')

[You might want to coerce that to a factor if you wish.]

Andy

> From: Shaw, Philip (NIH/NIMH)
> 
> Hi
>  
> 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!
>  
> Philip 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list