我有两个数据帧df1和df2。它们具有相同(两列)的列。我想从df2中的df1中删除行。
最佳答案
您可以使用几个软件包来做到这一点。但是,这是使用基数R的方法。
df1 <-matrix(1:6,ncol=2,byrow=TRUE)
df2 <-matrix(1:10,ncol=2,byrow=TRUE)
all <-rbind(df1,df2) #rbind the columns
#use !duplicated fromLast = FALSE and fromLast = TRUE to get unique rows.
all[!duplicated(all,fromLast = FALSE)&!duplicated(all,fromLast = TRUE),]
[,1] [,2]
[1,] 7 8
[2,] 9 10
关于R:从一个数据框中删除在另一数据框中的行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10907359/