[R] distance matrix

From: Jose Andres <jaa53_at_cornell.edu>
Date: Sat 29 Jul 2006 - 08:13:30 EST

Hi all,

I have a set of points (1...n) each of them defined on a 3D space
(i.e. for each point I do have x,y,z coordinates), and I would like
to generate a mean pairwise geometrical distance between them. Is there anyway I can do this with R?

Conceptually is really simple. First I have to generate a distance matrix (let's say "distmat") of pairwise distances (d= sqrt((x1-x2)^2 + (y1-y2)^2+(z1-z2)^2) and then calculate the mean -- mean.matrix
(distmat) -- . However, I do not know how I can generate the distance
matrix using R. I'd really appreciate all your suggestions/comments.

So, I have

        x y z

1 x1 y1 z1

2 x2 y2 z2

:	:		:		:
n	xn		yn		zn

and need

		1		2	..	n
1		-

2		d12		-

n		d1n		d2n		-

So I can calculate mean din

Thanks in advance!!!!!



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 and provide commented, minimal, self-contained, reproducible code. Received on Sat Jul 29 08:17:55 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 29 Jul 2006 - 10:16:58 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.