在R中从另一个表中删除一个表

问题描述:

我在R中有一个数据表,称为A,它具有三列Col1,Col2和Col3。另一个名为B的表也具有相同的三列。我想删除表A中表B中存在对(Col1,Col2)的所有行。我试过了,但我不确定如何执行此操作。最近几天我一直在坚持。

I have a data table in R, called A, which has three columns Col1, Col2, and Col3. Another table, called B, also has the same three columns. I want to remove all the rows in table A, for which the pairs (Col1, Col2) are present in table B. I tried, but I am not sure how to do this. I am stuck on this for last few days.

谢谢,

我们可以使用 anti_join

library(dplyr)
anti_join(A, B, by = c('Col1', 'Col2'))