Many thanks for reading. Apologies for what I\'m sure is a simple task.
I have a dataframe: (Edited: Added extra column not to be included in comparison)
<
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