I face a Problem in R which I can't handle myself.
I have a data frame that looks like this with more variables und cases:
ID Var1 Var2 Var3 Var4
1 1 0 1 1
2 0 0 0 0
3 1 1 1 1
4 1 1 0 1
5 1 0 1 0
I like to have — similar to a correlation matrix — a matrix that shows the frequency that a pair of variables have the same value — for example the value "1". The resulting matrix for the df above should then be like.
Var1 Var2 Var3 Var4
Var1 2 3 3
Var2 1 2
Var3 2
Var4
Perhaps you can help. Thank you in advance.