Skip to content
Prev 164675 / 398503 Next

Extract rows from data frame based on row names from anotherdata frame

Matching row names was the request.

# continuing with your example:

  rownames(d1)<- letters[1:5]
  rownames(d2)<- letters[3:7]

# and then for rownames of d1 that are also in rownames of d2:
# for the full rows ...

d1[row.names(d1) %in% row.names(d2),]

# or for just the names:

rownames(d1)[row.names(d1) %in% row.names(d2)]

--  
David Winsemius
On Dec 11, 2008, at 4:21 PM, Daniel Malter wrote: