[R] Extrat rows from a dataframe based on second data frame

Bansal, Vikas vikas.bansal at kcl.ac.uk
Mon Jul 25 18:00:08 CEST 2011


Dear all,

I have also attached my question in txt file because of bad column spacing.

I have two data frames

df

Chr            Pos         CaseA     CaseC        CaseG     CaseT
  10 135349878  0.000000  3.428571  0.000000 20.571429
  10 135349880  0.000000 21.333333  0.000000  2.666667
  10 135349883 21.000000  0.000000  3.000000  0.000000
  10 135349912  0.000000  0.000000 21.000000  3.000000
  10 135349913  0.000000 21.000000  0.000000  3.000000


mydf

V1        V2       V3 V4 V5 V6 V7 V8    V9        V10
 10 135349459  a  A 14  0  0  7   ,.,,,.,    bSa`^aa
 10 135349878  a  A 11  0  0  7   ,,,,,..    aaab^ab
 10 135349877  g  G 18  0  0  7   ,,,,,..   `a`_\\`b
 10 135349912  g  G 18  0  0  8  ,,,,,..,   `_abXbba
 10 135349881  a  A 14  0  0  8  ,,,,..,.   a`_aab_a

I want to have a new data frame with all rows in mydf whose 2nd column matches the second column of df.
so output of new data frame-

newdf

V1       V2       V3 V4 V5 V6 V7 V8    V9        V10
 10 135349878  a  A 11  0  0  7   ,,,,,..    aaab^ab
 10 135349912  g  G 18  0  0  8  ,,,,,..,   `_abXbba

Can you please help me.I will be very thankful to you.



Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: problem.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110725/aa37c4c4/attachment.txt>


More information about the R-help mailing list