I want to identify the unmatched values in Vendors data frame for each vendor. In other words, find the countries that are not located in the Vendors data frame for each vendor.
I have a data frame (Vendors) that looks like this:
Vendor_ID | Vendor | Country_ID | Country |
---|---|---|---|
1 | Burger King | 2 | USA |
1 | Burger King | 3 | France |
1 | Burger King | 5 | Brazil |
1 | Burger King | 7 | Turkey |
2 | McDonald's | 5 | Brazil |
2 | McDonald's | 3 | France |
Vendors <- data.frame (
Vendor_ID = c("1", "1", "1", "1", "2", "2"),
Vendor = c("Burger King", "Burger King", "Burger King", "Burger King", "McDonald's", "McDonald's"),
Country_ID = c("2", "3", "5", "7", "5", "3"),
Country = c("USA", "France", "Brazil", "Turkey", "Brazil", "France"))
and I have another data frame (Countries) that looks like this:
Country_ID | Country |
---|---|
2 | USA |
3 | France |
5 | Brazil |
7 | Turkey |
Countries <- data.frame (Country_ID = c("2", "3", "5", "7"),
Country = c("USA", "France", "Brazil", "Turkey"))
Desired Output:
Vendor_ID | Vendor | Country_ID | Country |
---|---|---|---|
2 | McDonald's | 2 | USA |
2 | McDonald's | 7 | Turkey |
Can someone please tell me how could this be achieved in R? I tried subset & ant-join but the results are not correct.