Compare group of two columns and return index matches R

久未见 提交于 2019-11-29 15:37:35

You could do something like this. It splits the row indices 1:nrow(df) according to unique sorted strings formed from the columns of df. The sorting ensures that A,B and B,A are treated identically.

duplist <- split(1:nrow(df),apply(df,1,function(r) paste(sort(r),collapse=" ")))

duplist
$`alan edd`
[1] 2 6

$`alex david`
[1] 1

$`ben pete`
[1] 3 4

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