[R] ifelse reformulation

arun
Fri, 12 Oct 2012 16:50:33 -0000

HI,
Try this:
count40<- ifelse(test1$x3==40|test1$x4==40|test1$x5==40,0,1)
count40
# [1] 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1
as.vector(apply(test1,1,function(x) ifelse(any(x[4:6]==40),0,1)))
# [1] 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1
A.K.



----- Original Message -----
From: brunosm <brunosm87 at gmail.com>
To: r-help at r-project.org
Cc:
Sent: Friday, October 12, 2012 10:18 AM
Subject: Re: [R] ifelse reformulation

That was exacly what i was looking for! Thanks a lot!
Cheers!



--
View this message in context:
http://r.789695.n4.nabble.com/ifelse-reformulation-tp4645981p4645990.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at 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.