For example DF1 is:
Id1 Id2
1 10
2 10
3 7
4 7
5 10
And want DF2:
Id1 Id2
1 2
1 5
2 5
3 4
The data frame DF2 is a pairwise set of values from Id1 column in DF1 that shared a common value in Id2 of DF1.
My attempt:
temp <- do.call("cbind", split(DF1, rep(c(1,2), length.out = nrow(DF1))))
(DF2 <- temp %>% select("1.Id1", "2.Id2"))
But this does not generate a pairwise data frame:
Id1 Id2
1 2
3 4