0
votes

Suppose i have two data frames, DF1 and DF2

DF1:

CustomerID     Name      PurchaseCode
1              Drue       1234
2              David      1222
3              Chris      1333
5              Kenny      3122

And

DF2:
CustomerID         Name      PurchaseCode
1                  Drue       1234
4                  Gimmy      1222
3                  Chris      1333

Now i want to filter DF1 by the Unique combination of CustomerID and PurchaseCode in DF2

So my filtered data frame would look like that:

CustomerID     Name      PurchaseCode
 1             Drue       1234
 3             Chris      1333

Notice that 'Gimmy' from DF2 has PurchaseCodethat appears in DF1, but his CustomerID does not match to the unique combination in DF1, so 'Gimmy' will not appear in the filtered data frame.

1

1 Answers

0
votes

Consider anti_join(DF1, DF2, by = c("PurchaseCode", "CustomerID"). Also definitely read the documentation on joins in dplyr.