Remove duplicated rows

前端 未结 11 1777
清酒与你
清酒与你 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 01:00

    Or you could nest the data in cols 4 and 5 into a single row with tidyr:

    library(tidyr)
    df %>% nest(V4:V5)
    
    # A tibble: 1 × 4
    #                      V1    V2    V3             data
    #                               
    #1 platform_external_dbus   202    16 
    

    The col 2 and 3 duplicates are now removed for statistical analysis, but you have kept the col 4 and 5 data in a tibble and can go back to the original data frame at any point with unnest().

提交回复
热议问题