[R] filtering data frame based on two columns

From: sun <flyhyena_at_yahoo.com.cn>
Date: Fri, 11 Jan 2008 13:19:55 +0100


 I have a data frame df with column names a,b and c.

 Now I want to get a subset of df that satified the condition a == 1 and b == 2, how do I specify this.

 For one condition like a == 1 I can use subdf = df[,df$a==1] to get the right answer, but
subdf = df[,df$a==1 && df$b ==2] does not return the right answer.

Some quick tips please.

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. Received on Fri 11 Jan 2008 - 12:27:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Jan 2008 - 13:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive