I have about 20,000 unique identifiers in a column in one dataframe. I want to filter the data from a second, larger dataframe (about 180,000 rows) so that only the rows with matching identifiers are left.
So, dataframe 1 looks something like this
df1 <- c("identifierab1","identifier56gh","identifier4znvh2")
dataframe 2 has 72 columns but one of the columns also has identifiers
df2$relevantcolumn <- c("identifierab1", "identifierab1", "identifier9472bh")
Ultimately, I want to filter df2 so that the only rows left are the rows in which df2$relevantcolumn
matches the values in df1
. I have tried %in%
and matches
but nothing seems to work..