I have two data frames (bwenv and bwsp). bwsp is a subset of bwenv and they have matching rownames (sample id). I would like to subset bwenv so that it only includes the rows that are also found in bwsp.
When the number of rows match, I have used:
bw2015 <- cbind(bwenv, bwsp)
to create a new dataframe with the combined data.
My question is very similar to the question asked here: R subset a column in data frame based on another data frame/list, but the subsetting is done by a column of data in each dataframe (rather than row names like I want to do).