[R] remove rows by a list of rownames

JSHuang js.huang at protective.com
Thu Jan 29 01:07:36 CET 2015


Hi,

  I think what you did is correct.  The row name 'comp168081_c2_seq1' is not
in the filter data frame.  Neither is the row as the following small example
shows.  Actually the dim(datawithoutVF) 171417     12 
is different from dim(data)  171471     12. Or 171417 is not the same as
171471 although they have the same digits in different order in the last
three digits.
 

  Here I use your data renamed as rHelpData and want to get rid of the first
three rows with row names stored in remove.  Then I use the statement
partData <- rHelpData[!rownames(rHelpData) %in% remove,] to store the result
in partData.  Then the content of partData shows the first three rows are
filtered out.  

  Hope this helps!

> rHelpData
                   apo1_LO apo2_LO apo3_LO apo4_LO lux1_LO lux2_LO lux3_LO
lux4_LO WT1_LO WT2_LO WT3_LO WT4_LO
comp230955_c0         0.00    8.05    8.15   32.91    0.00   38.41    0.00  
17.45  16.59   0.00   0.00   0.00
comp135535_c0_seq1    1.00    0.00    0.00    0.00    0.00    0.00    0.00   
0.00   0.00   1.00   1.00   0.00
comp222610_c5_seq4    4.96    8.21    1.84    5.57   14.59    6.54    6.51   
3.78   5.43  11.87   6.01   1.99
comp227842_c8_seq3   93.53  131.08   79.54  198.85  166.32  108.80   43.79 
125.63  45.37  34.13 103.42  67.90
comp230019_c3_seq1  141.97  355.04  142.11   71.02  497.84  424.01  212.69 
142.03  70.95  70.54  70.93 142.23
comp215198_c1_seq3   18.27   28.28   10.52    0.00   64.35    0.00    0.00  
21.05  17.74   0.00  19.66   0.00
> remove <- c("comp230955_c0","comp135535_c0_seq1","comp222610_c5_seq4")
> partData <- rHelpData[!rownames(rHelpData) %in% remove,]
> partData
                   apo1_LO apo2_LO apo3_LO apo4_LO lux1_LO lux2_LO lux3_LO
lux4_LO WT1_LO WT2_LO WT3_LO WT4_LO
comp227842_c8_seq3   93.53  131.08   79.54  198.85  166.32  108.80   43.79 
125.63  45.37  34.13 103.42  67.90
comp230019_c3_seq1  141.97  355.04  142.11   71.02  497.84  424.01  212.69 
142.03  70.95  70.54  70.93 142.23
comp215198_c1_seq3   18.27   28.28   10.52    0.00   64.35    0.00    0.00  
21.05  17.74   0.00  19.66   0.00



--
View this message in context: http://r.789695.n4.nabble.com/remove-rows-by-a-list-of-rownames-tp4702427p4702431.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list