I have a list of variables occurring across different studies. Each variable is coded with 1 if it is present in the given study and with 0 if it not, with the table looking like this:
var1 var2 var3
study1 1 0 0
study1 1 0 1
study1 0 0 0 etc.
My objective is to create a table with the number of times each variable occurs together with each of the other variables, i.e. something like this:
var1 var2 var3
var1 - 2 4
var2 2 - 1
var3 4 0 - etc.
How can I do this in R?
I have tried to look for a guide or a similar question, but come up empty.
Thank you in advance for your help!