I have pairwise distances that I need to display/convert into a distance matrix. R should have a function for this but I am not sure which one or how to use the same. My data looks like below
A1 A1 0.90
A1 B1 0.85
A1 C1 0.45
A1 D1 0.96
B1 B1 0.90
B1 C1 0.85
B1 D1 0.56
C1 C1 0.55
C1 D1 0.45
D1 D1 0.90
I want to convert/display it as below
A1 B1 C1 D1
A1 0.90 0.85 0.45 0.96
B1 0.90 0.85 0.56
C1 0.55 0.45
D1 0.90
What should I do? Thanks
You could use
reshape
:The solution mentioned by @alexis_laz seems to be more elegant: