[R] ifelse reformulation
arun
smartpink111 at yahoo.com
Fri Oct 12 18:50:33 CEST 2012
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.
More information about the R-help
mailing list