I'm working with a large database and I want to see which variables are most often found in each other's environment (i.e. in the same row). There can be more than 20 variables in a row and I don't know all of them.
Here is an example:
var1 <- c("x", "x", "x", "x", "x", "x", "y", "y", "y", "y")
var2 <- c("a", "a", "b", "b", "c", "d", "e", "e", "g", "h")
data <- data.frame(cbind(var1, var2))
The result should look like this:
|frequent contacts|n|
x&a 2
x&b 2
y&e 2
x&c 1
etc.