[R] filter data from data frame

John Kane jrkrideau at yahoo.ca
Tue Feb 12 23:22:23 CET 2008


?merge

Let the data.frame be xx

yy <- data.frame(ORF=
c("YAL026C","YAL041W","YAL048C","YAL007C","YAL012W",
       "YAL016W" ))
 
 merge(xx,yy, by="ORF")

should do it.
--- Roberto Olivares Hernandez <roh at bio.dtu.dk> 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
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.
>



More information about the R-help mailing list