I am dealing with a set of variables that look something like below
IndexA IndexB
1 A B
2 B A
3 A C
I would like to remove all duplicates where A is in B and B is in A. So that the resulting dataset looks like this:
IndexA IndexB
1 A B
2 A C
I have managed to obtain a list of all of the duplicates using subsetting e.g.
duplicates<-df[df$IndexA %in% df$IndexB & df$IndexB %in% df$IndexA,]
However, I want to be able to retain only one of the duplicates that is returned for each case where df$IndexA %in% df$IndexB & df$IndexB %in% df$IndexA