EDIT: My question was closed with a reference to merge/join operators. The difference to a normal join is that I just want to keep the unmatched rows. How can I achieve this?
I want to filter this "df" for entries that are not in the "other_df" with R. For example this data table: df:
Person_ID | School | Year |
---|---|---|
1 | A | 2015 |
1 | B | 2015 |
1 | B | 2016 |
other_df:
Person_ID | School | Year |
---|---|---|
1 | A | 2015 |
2 | A | 2017 |
1 | B | 2016 |
As a new df, I would like to receive this:
Person_ID | School | Year |
---|---|---|
1 | B | 2015 |
1 | B | 2016 |
df = df %>% filter(!(Person_ID %in% other_df$Person_ID & School %in% other_df$School
& Year %in% other_df$Year))
This operation gives me an empty df... I think that is because the three conditions are not connected and every single one is in the "other_df", but I dont know how to do it properly.
As an addition I would have to add that there are more than these 3 columns, but I dont want to filter with them but still keep them.