I'm having trouble to make from my data.frame a square matrix. Now my data looks something like this:
var1 var2 value
A B 4
C D 5
D A 2
B D 1
I'm trying to transform the data.frame to a matrix that looks like this:
A B C D
A 0 4 0 2
B 4 0 0 1
C 0 0 0 5
D 2 1 5 0
I tried many functions from the different package available in R but still cannot find a solution.