Re: [R] filter data from data frame

From: Romain Francois <rfrancois_at_mango-solutions.com>
Date: Tue, 12 Feb 2008 15:36:38 +0000

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
>
______________________________________________ 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 Tue 12 Feb 2008 - 15:53:20 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 Tue 12 Feb 2008 - 16:30:13 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