[R] filter data.frame

Ivan Calandra ivan.calandra at uni-hamburg.de
Thu Oct 7 10:49:51 CEST 2010


  Hi,

Try this:
subset(data, subset=(X3==3 & X2==2 & X1==2))
   X1 X2 X3
3  2  2  3

First, you have numerical values, so don't quote them.
Second, take a look at ?"&&" to understand the difference between & and &&.

HTH,
Ivan


Le 10/7/2010 10:43, behave a écrit :
> hi all,
>
> how do I filter a dataframe.
>
> What I am looking for is something like:
>
> data<-data.frame(matrix(c(2,2,1,2,2,2,2,2,3),byrow=TRUE,ncol=3))
> subset(data, subset=(X3=="3"&&  X2=="2"&&  X1=="2"))
>
> thanks
>
>

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php



More information about the R-help mailing list