R: Remove duplicates from a dataframe based on categories in a column

前端 未结 7 1216
耶瑟儿~
耶瑟儿~ 2021-02-15 16:14

Here is my example data set:

      Name Course Cateory
 1: Jason     ML      PT
 2: Jason     ML      DI
 3: Jason     ML      GT
 4: Jason     ML      SY
 5: Ja         


        
7条回答
  •  独厮守ぢ
    2021-02-15 16:22

    You're not removing based on category, you're really trying to remove full duplicate rows from the dataframe.

    You can remove full duplicate rows by subsetting the dataframe:

    base R:
    df_without_dupes <- df[!duplicated(df),]
    

提交回复
热议问题