duplicates in multiple columns

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 20:08:20

It works if you use duplicated twice:

df[!(duplicated(df[c("c","d")]) | duplicated(df[c("c","d")], fromLast = TRUE)), ]

  a  b c    d
1 1  2 A 1001
4 4  8 C 1003
7 7 13 E 1005
8 8 14 E 1006

Make a new object with the 2 columns:

df_dups <- df[c("c", "d")]

Now apply it to your main df:

df[!duplicated(df_dups),]

Looks neater and easy to see/change columns that you are using.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!