On re-reading ?cmdscale I see that I can also use cmdscale(d) on a
full matrix rather than just the lower triangle.
 d: a distance structure such as that returned by 'dist' or a
          full symmetric matrix containing the dissimilarities.

So how to get a full symmetric matrix from a dataframe like this (toy example)?
 x       y       z
 "a"     "a"     0
 "a"     "b"     1
 "a"     "c"     2
 "b"     "a"     .9
 "b"     "b"     0
 "b"     "c"     1.3
 "c"     "a"     2.2
 "c"     "b"     1.1
 "c"     "c"     0

Replacing the corresponding cells in the matrix by their means, I need this:

 c 2.10 1.20 0.00
 b 0.95 0.00 1.20
 a 0.00 0.95 2.10
  a    b    c

E.g. in the original data, the cell (a,b) = 1; (b, a) =0.9. In the
final matrix, (a,b) = (b,a) =0.95

 Thanks very much for any help.

Bill

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to