to start of I would do something like :
df1 <- data.frame(
stringsAsFactors = FALSE,
source = c("a", "b", "c", "d", "e", "c", "a", "e", "a"),
target = c("b", "c", "d", "e", "a", "b", "d", "d", "e"),
selection1 = c(1, 0, 1, 0, 0, 1, 1, 0, 0),
selection2 = c(1, 1, 0, 0, 1, 1, 0, 0, 1),
selection3 = c(1, 1, 1, 1, 1, 0, 0, 0, 0)
)
(identify_possibles <- group_by(
df1,
selection1,
selection2,
selection3
) %>% group_modify(
~ if (nrow(.) > 1) {data.frame(.)} else { data.frame() }
) )
as some selections are unique and so dont have source-target combinations to assess - best strip them out and focus on those that do. the above code produces a new (grouped) table of the selections worth further investigating.
Then I would try to integrate my solution here:
conceptually it seems the same its just that first name is source and last name is target.
good luck