r - Select rows from data.frame using vector of names -
i keep ~1200 rows data.frame
remove rest of rows have use vector of "gene names" can found in data.frame
.
my data (just couple of rows):
> tbl_ready2 gene.name x1_1 x1_2 x1_3 x1_4 x1_5 x1_6 x1_7 x1_8 x1_9 x1_10 x1_11 x1_12 x1_13 x1_14 x1_15 x1_16 x1_17 1 at1g01050 0 0 0.000000 0.000000 0.0000000 0.0000000 0.7137613 0.0000000 1.1431194 0.0000 0.0000000 0 0.000000 0.0000000 0 0.0000000 0.000000 2 at1g01080 0 0 1.912532 1.263598 0.9972625 0.8363335 0.9984333 1.0027375 0.7207666 0.0000 0.7155959 0 0.000000 0.0000000 0 0.0000000 0.000000 3 at1g01090 0 0 0.000000 0.000000 0.0000000 0.1864505 0.0000000 0.1057995 0.7634527 0.9794 1.1207689 1 1.276209 0.9701439 0 0.8552922 0.000000 4 at1g01220 0 0 0.000000 0.000000 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000 0.0000000 0 0.000000 0.0000000 0 0.0000000 0.000000 5 at1g01320 0 0 0.000000 0.000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000 1.0000000 1 1.106175 0.8972847 0 0.6782750 1.313616 x1_18 x1_19 x1_20 x1_21 x1_22 x1_23 x1_24 1 0.0000000 0.000000 0 0.000000 0 0 0.0000000 2 0.0000000 0.000000 0 0.000000 0 0 0.5538011 3 1.0182444 2.138711 0 1.554696 0 0 1.6815517 4 0.0000000 0.000000 0 0.000000 0 0 0.0000000 5 0.7313952 1.268605 0 2.128264 0 0 1.0000000
vector of names (not of them):
> vec [1] at1g02500 at1g07780 at1g08250 at1g08630 at1g09780 at1g09795 at1g10060 at1g10070 at1g11790 at1g12230 at1g13440 at1g14810 at1g15710 at1g16300 at1g17290 [16] at1g17745 at1g18500 at1g18640 at1g22020 at1g22170 at1g22410 at1g23310 at1g24807 at1g24909 at1g25083 at1g25155 at1g25220 at1g29410 at1g31180 at1g31230 [31] at1g31860 at1g32380 at1g32440 at1g32480 at1g33320 at1g36370 at1g44820 at1g48470 at1g48850 at1g48860 at1g50090 at1g50110 at1g54100 at1g54340 at1g55880 [46] at1g55920 at1g56190 at1g58080 at1g62800 at1g63290 at1g65930 at1g69370 at1g70580 at1g71100 at1g71920 at1g72330 at1g72810 at1g74030 at1g74040 at1g75330
so tried function. thought should work doesn't...
data <- tbl_ready[intersect(vec, tbl_ready[,1])]
any ideas ?
you using tbl_ready , tbl_ready2 in example. if tbl_ready2 data.frame want subset, try:
data<-tbl_ready2[tbl_ready2$gene.name %in% vec,]
Comments
Post a Comment