jeudi 29 septembre 2016

R grep rows within a list

I have many data frame, so I import them as a list and I would like to grep the specific pattern in rows to create a data frame which contains only the specific pattern rows.

list
[1]
TBBA-06-5415-01A-01D-1481-05    g02726808   0.956810536587318   BSL
TBBA-06-5415-01A-01D-1481-05    g03242877   0.0365834311749085  BSL
TBBA-06-5415-01A-01D-1481-05    g06008330   0.0400302305964602  BSL
TBBA-06-5415-01A-01D-1481-05    g08861569   0.0556296569207048  BSL
TBBA-06-5415-01A-01D-1481-05    g09748749   0.183017407923698   BSL
[2]
TBBA-62-A472-01A-11D-A24I-05    g02726808   0.860054268107413   OTB
TBBA-62-A472-01A-11D-A24I-05    g04243127   0.897393495417269   OTB
TBBA-62-A472-01A-11D-A24I-05    g10537079   0.875143441641266   OTB
TBBA-62-A472-01A-11D-A24I-05    g12497728   0.935925242951832   OTB
TBBA-62-A472-01A-11D-A24I-05    g13195463   NA  OTB
[3]
TBBA-KK-A7AV-01A-11D-A32C-05    g02726808   0.862838460053133   AS
TBBA-KK-A7AV-01A-11D-A32C-05    g11045524   0.369049794350982   AS
TBBA-KK-A7AV-01A-11D-A32C-05    g13597397   0.235754213039205   AS
TBBA-KK-A7AV-01A-11D-A32C-05    g13835114   0.155860360642954   AS
TBBA-KK-A7AV-01A-11D-A32C-05    g14010829   0.668836842295365   AS
[N]
...

Desired output:
TBBA-06-5415-01A-01D-1481-05    g02726808   0.956810536587318   BSL
TBBA-62-A472-01A-11D-A24I-05    g02726808   0.860054268107413   OTB
TBBA-KK-A7AV-01A-11D-A32C-05    g02726808   0.862838460053133   AS
....

I would like to grep the second column the pattern g02726808 and grep each that row into a data frame. Thank you!

Aucun commentaire:

Enregistrer un commentaire