I would try the "igraph" package after using crossprod
on your data. Assuming your data.frame
is called "mydf":
out <- crossprod(t(mydf))
out[lower.tri(out, diag=TRUE)] <- 0
library(igraph)
g <- graph.adjacency(out)
get.edgelist(g)
# [,1] [,2]
# [1,] "A" "B"
# [2,] "A" "C"
# [3,] "A" "D"
# [4,] "B" "C"
# [5,] "B" "D"
# [6,] "B" "D"
# [7,] "C" "D"
If you don't want duplicates, you can use:
g <- graph.adjacency(out > 0)
get.edgelist(g)