0

Suppose that we are given a data table/frame in R:

  ID_number       Name
   001            Adam
   002            Adam
   003            Sam
   004            Nike
   005            James
   006            James

How can I remove the rows that have duplicate IDs or just take the rows that have unique IDs? In this case, we should get the sub table:

  ID_number       Name
   003            Sam
   004            Nike

Thanks for the help!

awivil
  • 1
  • 1

1 Answers1

0

We can remove the duplicated rows with duplicated

df1[!(duplicated(df1$Name)|duplicated(df1$Name, fromLast = TRUE)),]
akrun
  • 874,273
  • 37
  • 540
  • 662