[R] Compare two distance matrices

Mattias de Hollander mdehollander at gmail.com
Thu Oct 6 12:23:24 CEST 2005


Hi all,

I am trying to compare two distance matrices with R. I would like to
create a XY plot of these matrices and do some linear regression on
it. But, I am a bit new to R, so i have a few questions (I searched in
the documentation with no success).
The first problem is loading a distance matrix into R. This matrix is
the output of a the Phylip program Protdist and lookes like this:
    5
n_crassa    0.000000  0.690737  0.895257  0.882576  2.365386
c_neufor    0.690737  0.000000  0.956910  0.979988  2.103041
a_thaliana  0.895257  0.956910  0.000000  1.003668  2.724847
pompep      0.882576  0.979988  1.003668  0.000000  2.065202
s_cerevis   2.365386  2.103041  2.724847  2.065202  0.000000
    5
n_crassa    0.000000  0.739560  0.933986  0.861644  2.207467
c_neufor    0.739560  0.000000  0.988779  0.925168  1.941141
a_thaliana  0.933986  0.988779  0.000000  1.007803  2.415320
pompep      0.861644  0.925168  1.007803  0.000000  2.394490
s_cerevis   2.207467  1.941141  2.415320  2.394490  0.000000
.....

I tried with the scan() function to load the files, but with no
success. How should i load in these files?

Second i saw there is package for distance matrices
(http://stat.ethz.ch/R-manual/R-devel/library/stats/html/dist.html). I
thought of using as.dist() to convert the files to a R dist matrix. I
have not been able to try this, because the first step didn't succeed.

Is this the right approach, or is there any other way of comparing
distance matrices with R?




More information about the R-help mailing list