0

I have a data.frame testthat looks like the following:

> test <- data.frame(X=c(1, 3, 2, 1), Y=c(2, 2, 1, 3), Z=c("A", "B", "C", "D"))
> test
  X Y Z
1 1 2 A
2 3 2 B
3 2 1 C
4 1 3 D

I want to be able to remove any row where there is an un-ordered duplicate pair. More specifically, where in the first row X = 1 and Y = 2, it's un-ordered duplicate pair is found on the 3rd row where in this instance X = 2 and Y = 1 -- I'd like to remove the either entry of the two. The resulting data.frame should look like:

> final.test
  X Y Z
1 1 2 A
2 3 2 B
4 1 3 D

Any help would be much appreciated :)

Jaap
  • 77,147
  • 31
  • 174
  • 185
Steven_
  • 708
  • 1
  • 7
  • 20
  • 1
    See [this post](http://stackoverflow.com/questions/21194611/extracting-unique-combination-rows-from-a-data-frame-in-r) and [this post](http://stackoverflow.com/questions/9028369/removing-duplicate-combinations-in-r-irrespective-of-order) – alexis_laz Mar 04 '16 at 20:15
  • Also http://stackoverflow.com/q/15487151/1191259 which leads to `test[, c("X","Y")] – Frank Mar 04 '16 at 20:24

0 Answers0