[R] filter data from data frame

Romain Francois rfrancois at mango-solutions.com
Tue Feb 12 16:36:38 CET 2008


Hi Roberto,

One of these ?

 > Y[ Y$ORF %in% X , ]
       ORF spectra
3  YAL007C       2
4  YAL012W       8
5  YAL016W      24
11 YAL026C       2
16 YAL041W       4
18 YAL048C       1

 > subset( Y, ORF %in% X )
       ORF spectra
3  YAL007C       2
4  YAL012W       8
5  YAL016W      24
11 YAL026C       2
16 YAL041W       4
18 YAL048C       1

Cheers,

Romain

-- 
Mango Solutions
data analysis that delivers

Introduction to R training course :: London :: 06-07 March 2008
http://www.mango-solutions.com/services/rtraining/r_intro.html







Roberto Olivares Hernandez wrote:
> Hi,
> I have a data frame Y with the following information,
>
>    ORF          spectra
> 1  YAL001C      2
> 2  YAL005C      21
> 3  YAL007C      2
> 4  YAL012W      8
> 5  YAL016W      24
> 6  YAL019W      3
> 7  YAL020C      2
> 8  YAL021C      7
> 9  YAL022C      3
> 10 YAL023C      6
> 11 YAL026C      2
> 12 YAL029C      1
> 13 YAL031C      1
> 14 YAL035W      48
> 15 YAL038W      173
> 16 YAL041W      4
> 17 YAL042W     4
> 18 YAL048C      1
> 19 YAL049C      1
> 20 YAL051W     1
>
>
> In the other hand I have this object X with character elements as following
>
> "YAL026C"
> "YAL041W"
> "YAL048C"
> "YAL007C"
> "YAL012W"
> "YAL016W"
>
> and I want to generate a new data frame exclusively with the elements from the object X and its respective spectra value from the data frame Y. how to do it?
>
> I have tried to look into several functions, match, subset, command Y[ X, ], and I still can not get it
>
>
> thanks in advance
>
> Roberto
>



More information about the R-help mailing list