The anti_join: which records did NOT match the other table?
Joins can be tricky and sometimes we want to check which records did NOT match the other table (the exception, of course, is the full-join). For this problem, the anti_join in R can help.
Let's create a simple table_1:
And a table_2:
In my lef_join, I see the returned data which will be joined.
In the last code snippet, I use the anti_join. With the anti_join, we get all the rows from table_1 which will not be joined from table_2. The anti_join can be really useful in analyzing whether we get all the data (i.e. rows) we need.
I believe the anti_join is more useful than the semi_join which returns all rows which will be joined.