19 Aug 22:07
conditional with and operators
From: Altaweel, Mark R. <maltaweel <at> anl.gov>
Subject: conditional with and operators
Newsgroups: gmane.comp.lang.r.general
Date: 2008-08-19 20:10:11 GMT
Subject: conditional with and operators
Newsgroups: gmane.comp.lang.r.general
Date: 2008-08-19 20:10:11 GMT
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
______________________________________________
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.
RSS Feed