-6

I have got the following data.frame:

df = read.table(text = 'a    b   c   d
                        1   12   2   1
                        1   13   2   1
                        1    3   3   1
                        2   12   6   2
                        2   11   2   2
                        2   14   2   2
                        1   12   1   2
                        1   13   2   2
                        2   11   4   3, header = TRUE')

I need to remove the rows which have the same observations based on columns a and b, so that the results would be:

                        a    b   c   d
                        1   12   2   1
                        1   13   2   1
                        1    3   3   1
                        2   12   6   2
                        2   11   2   2
                        2   13   2   2

Thank you for any help

aaaaa
  • 149
  • 2
  • 18
  • 44

1 Answers1

-3

We can use duplicated

df[!duplicated(df[1:2]),]
akrun
  • 874,273
  • 37
  • 540
  • 662