[R] ifelse()

kayj kjaja27 at yahoo.com
Tue Feb 10 22:44:16 CET 2009


I have a problem with ifelse(), I do not understand how it works. 

> X<-c(2,2,1,1,0,0)
> str(X)
 num [1:6] 2 2 1 1 0 0
> Y<-ifelse(X>0,1,0)
> Y
[1] 1 1 1 1 0 0
>

Can some one explain what is going on, I do not understand what ifelse is
doing in this case. Can someone explain the output Y.

Thanks

-- 
View this message in context: http://www.nabble.com/ifelse%28%29-tp21943308p21943308.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list