I want to identify and remove observations which are duplicates in certain aspects.
In my example, I want to get rid of rows 1 and 6, as they are the same in both V1 and V2. That they differ in V3 shouldn't matter.
df <- data.frame(V1 = c("a","b","c","a","c","a"),
V2 = c(1,2,1,2,3,1),
V3 = c(1,2,3,4,5,6))
Applying dplyr::distinct(df, V1, V2) results in row 6 being discarded while row 1 remains. As I said, I want both rows 1 and 6 removed. I am sure the problem is trivial, but I can't think of the correct search terms ...
Thanks!
df[!(duplicated(df[c(1,2)]) | duplicated(df[c(1,2)], fromLast = TRUE)), ]