How to find common rows between two dataframe in R?

前端 未结 5 788
Happy的楠姐
Happy的楠姐 2020-12-30 02:21

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         


        
5条回答
  •  情歌与酒
    2020-12-30 02:52

    common <- intersect(data.frame1$col, data.frame2$col)  
    data.frame1[common,] # give you common rows in data frame 1  
    data.frame2[common,] # give you common rows in data frame 2
    

提交回复
热议问题