Hi, Ok that worked...im from a Java background so I guess Im used to the && rather than &
Thanks! Mark -----Original Message----- From: Steven McKinney [mailto:[EMAIL PROTECTED] Sent: Tue 8/19/2008 3:33 PM To: Altaweel, Mark R.; r-help@r-project.org Subject: RE: [R] conditional with and operators Did you try it with the vector '&' and operator? d<-sapply(res,function(.df){(.df$TimesVisited[.df$Tick>912 & .df$Id>0])}) (The '&&' operator is designed for use in e.g. if() clauses where you want a scalar logical answer) HTH Steve McKinney -----Original Message----- From: [EMAIL PROTECTED] on behalf of Altaweel, Mark R. Sent: Tue 8/19/2008 1:10 PM To: r-help@r-project.org Subject: [R] conditional with and operators 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@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. ______________________________________________ R-help@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.