Remove duplicated rows

前端 未结 11 1789
清酒与你
清酒与你 2020-11-22 00:00

I have read a CSV file into an R data.frame. Some of the rows have the same element in one of the columns. I would like to remove rows that are duplicates in th

11条回答
  •  無奈伤痛
    2020-11-22 00:51

    the general answer can be for example:

    df <-  data.frame(rbind(c(2,9,6),c(4,6,7),c(4,6,7),c(4,6,7),c(2,9,6))))
    
    
    
    new_df <- df[-which(duplicated(df)), ]
    

    output:

          X1 X2 X3
        1  2  9  6
        2  4  6  7
    

提交回复
热议问题