[R] conditional with and operators
Altaweel, Mark R.
maltaweel at anl.gov
Tue Aug 19 22:10:11 CEST 2008
Hi,
I have a problem in which I am parsing data from a list. I am simply trying to return data that has several conditions being true. Here is my syntax below:
d<-sapply(res,function(.df){(.df$TimesVisited[.df$Tick>912 && .df$Id>0])}) #res is the list, and I am trying to return a result that has two true conditions (that is the variable Tick should be greate than 912 and Id should be greater than 0
This returns an array of 10 with integer values of 0. This is the incorrect result
However, if I do the same syntax except I remove the && statement (i.e. the second conditional), then the result producing something that makes sense, which is all values that are Tick and greater than 912.
Can someone let me know how I can setup my data to be parsed so I can have 2 or multiple conditionals in my function that is looking at an array.
Thanks in advance.
Mark
More information about the R-help
mailing list