Is there a simple approach to converting a data frame with dummies (binary coded) on whether an aspect is present, to a co-occurrence matrix containing the counts of two aspects co-occuring?
E.g. going from this
X <- data.frame(rbind(c(1,0,1,0), c(0,1,1,0), c(0,1,1,1), c(0,0,1,0)))
X
X1 X2 X3 X4
1 1 0 1 0
2 0 1 1 0
3 0 1 1 1
4 0 0 1 0
to this
X1 X2 X3 X4
X1 0 0 1 0
X2 0 0 2 1
X3 1 2 0 1
X4 0 1 1 0