Hi all, Thanks for the quick response. I see the ade4 package in not needed for distance matrix computation, but as far i can see you need it for comparing two distance matrices. In the stats package i can't find any similiar functions like mantel.randtest or RVdist.randtest of the ade4 package. So i think this package is still needed if i would like to make a scatter plot of the matrices. Or should i manualy compare these matrices with a loop for example and make a plot of this?
On 10/6/05, Martin Maechler <[EMAIL PROTECTED]> wrote: > >>>>> "bady" == bady <[EMAIL PROTECTED]> > >>>>> on Thu, 06 Oct 2005 14:39:27 +0200 writes: > > bady> Hi, 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: > >> I tried with the scan() function to load the files, but with no > >> success. How should i load in these files? .... > >> > > bady> you can separately load each matrix with two text files. > > bady> require(ade4) > bady> mat1 <- read.table("mat1.txt") > bady> nam1 <- mat1[,1] > bady> mat1 <- mat1[,-1] > bady> row.names(mat1) <- names(mat1) <- nam1 > bady> mat2 <- read.table("mat2.txt") > bady> nam2 <- mat2[,1] > bady> mat2 <- mat2[,-1] > bady> row.names(mat2) <- names(mat2) <- nam2 > > bady> dist1 <- mat2dist(mat1) > bady> dist2 <- mat2dist(mat2) > > but I don't see why you would need an extra package "ade4" and > its "extra - function" mat2dist(). > > > when the 'stats' package already provides the function > as.dist(.) {the help page of which was mentioned by the > original poster}. > > > Here is a reproducible example showing how I think as.dist() > works sufficiently: > > > (m <- toeplitz(round(rnorm(6),2))) > [,1] [,2] [,3] [,4] [,5] [,6] > [1,] -0.42 -0.78 -0.42 -2.24 0.74 1.31 > [2,] -0.78 -0.42 -0.78 -0.42 -2.24 0.74 > [3,] -0.42 -0.78 -0.42 -0.78 -0.42 -2.24 > [4,] -2.24 -0.42 -0.78 -0.42 -0.78 -0.42 > [5,] 0.74 -2.24 -0.42 -0.78 -0.42 -0.78 > [6,] 1.31 0.74 -2.24 -0.42 -0.78 -0.42 > > as.dist(m) > 1 2 3 4 5 > 2 -0.78 > 3 -0.42 -0.78 > 4 -2.24 -0.42 -0.78 > 5 0.74 -2.24 -0.42 -0.78 > 6 1.31 0.74 -2.24 -0.42 -0.78 > > ## it also works for data frames {if really needed}: > > dm <- as.data.frame(m) > > as.dist(dm) > 1 2 3 4 5 > 2 -0.78 > 3 -0.42 -0.78 > 4 -2.24 -0.42 -0.78 > 5 0.74 -2.24 -0.42 -0.78 > 6 1.31 0.74 -2.24 -0.42 -0.78 > > > > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html