-3

I want to remove duplicated row: the first column C1 can be repetitive but if all others columns are the same as C2=C3=C4=C5 i need to keep only one copy :

example:

C1        C2          C3   C4   C5
7163003  17/09/2008   GE    A   45
7163003  17/09/2008   GE    A   45
7163003  08/06/2009   GE    B   50
7163003  22/12/2011   GE    C   45

Results:

C1        C2          C3   C4   C5
7163003  17/09/2008   GE    A   45
7163003  08/06/2009   GE    B   50
7163003  22/12/2011   GE    C   45
zx8754
  • 52,746
  • 12
  • 114
  • 209
S.ben
  • 3
  • 6

2 Answers2

2
mydata<-data.frame(C1=c(LETTERS,LETTERS),C2=c(LETTERS,LETTERS),C3=c(LETTERS,LETTERS),C4=c(LETTERS,LETTERS),C5=c(LETTERS,LETTERS))
mydata
mydata[!duplicated(mydata$C1),]
0

dplyr solution using distinct:

library(dplyr)

distinct(df)  

       C1         C2 C3 C4 C5
1 7163003 17/09/2008 GE  A 45
2 7163003 08/06/2009 GE  B 50
3 7163003 22/12/2011 GE  C 45
tyluRp
  • 4,678
  • 2
  • 17
  • 36