Remove duplicated rows

前端 未结 11 1984
清酒与你
清酒与你 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:39

    just isolate your data frame to the columns you need, then use the unique function :D

    # in the above example, you only need the first three columns
    deduped.data <- unique( yourdata[ , 1:3 ] )
    # the fourth column no longer 'distinguishes' them, 
    # so they're duplicates and thrown out.
    

提交回复
热议问题