[R] filtering data frame based on two columns

sun flyhyena at yahoo.com.cn
Fri Jan 11 13:19:55 CET 2008


Hi,

 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.




More information about the R-help mailing list