if I have a df such as the following:
df <- data.frame(pair1 = rep(c("Apple", "Banana", "Carrot"), 4),
pair2 = rep(c("Doughnut", "Carrot", "Banana", "Apple"), 3),
stringsAsFactors = FALSE)
Is there a quick way of removing rows that contain the same elements but transposed, e.g. if one row had pair1 = Apple and pair2 = Banana and another had pair1 = Banana and pair2 = Apple is there a way to identify these as repeats and just keep one?
I can do this using a for loop but my dataset is long and it takes a while to run. I was hoping that there might be a nifty command or package along the lines of dplyr that would implement this.