查找数据框的补码(反联接) [英] Find complement of a data frame (anti - join)
本文介绍了查找数据框的补码(反联接)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个数据帧(df和df1). df1是df的子集.我想获得一个数据帧,该数据帧是df中df1的补充,即第一个数据集的返回行与第二个数据集不匹配.例如让
I have two data frames(df and df1). df1 is subset of df. I want to get a data frame which is complement of df1 in df, i.e. return rows of the first data set which are not matched in the second. For example let,
数据帧df:
heads
row1
row2
row3
row4
row5
数据帧df1:
heads
row3
row5
则所需的输出df2为:
Then the desired output df2 is:
heads
row1
row2
row4
推荐答案
从dplyr
library(dplyr)
anti_join(df, df1, by='heads')
这篇关于查找数据框的补码(反联接)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文