I would like to make a new data frame which only includes common rows of two separate data.frame. example:
data.frame 1
1 id300
2 id2345
3 id5456
4 i
We can also do this with fintersect from data.table after converting the data.frame to data.table
library(data.table)
fintersect(setDT(df1), setDT(df2))
# v1
#1: id300
#2: id45
#3: id5456
df1 <- structure(list(v1 = c("id300", "id2345", "id5456", "id33", "id45",
"id54")), .Names = "v1", class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6"))
df2 <- structure(list(v1 = c("id832", "id300", "id1000", "id45", "id984",
"id5456", "id888")), .Names = "v1", class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7"))