R: Select subset of dataframe by non-unique ids
Posted
by amarillion
on Stack Overflow
See other posts from Stack Overflow
or by amarillion
Published on 2010-04-02T19:50:20Z
Indexed on
2010/04/02
19:53 UTC
Read the original article
Hit count: 275
Suppose I have a dataframe like this one:
df <- data.frame (id = c("a", "b", "a", "c", "e", "d", "e"), n=1:7)
and a vector with ids like this one:
v <- c("a", "b")
How can I select the rows of the dataframe that match the ids in v? I can't use the id column for rownames because they are not unique.
© Stack Overflow or respective owner