Skip to content

filtering a dataframe with a vector of rownames

5 messages · Jonathan Hughes, Phil Spector, ANJAN PURKAYASTHA +1 more

#
Jonathan -
    To make your approach work, you'd need to replace ==
with %in%:
[1] 1 3 4

But to answer you're original question, remember that the
point of rownames is that they can be used to index a 
data frame:
[,1] [,2]
a    1    2
c    3    4
d    4    5


 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Fri, 14 Jan 2011, Jonathan Hughes wrote:

            
#
On 14.01.2011 19:25, Jonathan Hughes wrote:
replace the last line by

  rows.to.keep <- data[names.to.keep,]

and please read the docs on indexing.

Best,
Uwe Ligges