First create a matrix of all pairs from the source list:
L <- list(c("John", "Mary", "Jack"), c("John", "Wendy"), c("Mary", "Wendy"))
x <- matrix(unlist(lapply(L, combn, 2, simplify = FALSE)), ncol = 2)
Then use one of the methods shown here: Matrix pair interaction in R . I like the one that uses graph theory tools :-)
library(igraph)
g <- graph.edgelist(x, directed = FALSE)
get.adjacency(g)
# John Jack Mary Wendy
# John 0 1 1 1
# Jack 1 0 1 0
# Mary 1 1 0 1
# Wendy 1 0 1 0
source
share