[英]Find the number overlap between two data frames
I have two data frames, one called gs
and the other called mmpc
. 我有两个数据框,一个叫做
gs
,另一个叫做mmpc
。 Each data frame has two columns, but a different number of rows. 每个数据框都有两列,但行数不同。 I am looking to find the number of rows that both data frames have in common.
我希望找到两个数据帧共有的行数 。 Does anyone know how to do this?
有谁知道如何做到这一点?
Note: the rows are not be in the same order between the two data frames, and the data frames have different numbers of rows. 注意:两个数据帧之间的行顺序不同,数据帧的行数不同。
一种选择是使用merge
:
nrow(merge(gs,mmpc,by.x=1:2,by.y=1:2))
其他方式:
sum(duplicated(rbind(gs, mmpc))[-seq_len(nrow(gs))])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.