Q:

finding indices of duplicate rows - follow up

i am looking for a way for a way to find indices of duplicate rows.
after searching here i found this - Find indices of duplicated rows
that looks good but i wanted to ask if there was a way to "clump" the indices of the repeated rows together. i tried asking this in a comment but the system won't let me. 
the thing is- i have duplicate cells in my DF. i need to know the location of both rows where there was a duplicate for me to go through the original data and which one of them is wrong. 
a simple output of which indices are duplicate means i still have to find the "twin" by myself.
any ideas?
again, i apologize for asking a new question when this is clearly a follow up to an already asked question.  

A:

Perhaps you want something like this, using the sample data from the related question:
df <- data.frame(a = c(1,2,3,4,1,5,6,4,2,1))
x <- lapply(df$a, function(x) which(df$a == x))
names(x) <- df$a

> x
#$`1`
#[1]  1  5 10
#
#$`2`
#[1] 2 9
#
#$`3`
#[1] 3
#
#$`4`
#[1] 4 8
#
#$`1`
#[1]  1  5 10
#
#$`5`
#[1] 6
#
#$`6`
#[1] 7
#
#$`4`
#[1] 4 8
#
#$`2`
#[1] 2 9
#
#$`1`
#[1]  1  5 10

You could also do:
df$twin <- sapply(x, toString)
#   a     twin
#1  1 1, 5, 10
#2  2     2, 9
#3  3        3
#4  4     4, 8
#5  1 1, 5, 10
#6  5        6
#7  6        7
#8  4     4, 8
#9  2     2, 9
#10 1 1, 5, 10

