From: Vayssières, Marc <marcv_at_water.ca.gov>

Date: Sat 25 Feb 2006 - 04:23:36 EST

xyz <- cbind(x,y,z)

xyz

d.all <- dist(xyz[,c("x","y")])

d.all

xyz.02 <- subset(xyz, z == 0 | z == 2)

xyz.02

d.02 <- dist(xyz.02[,c("x","y")])

d.02

xyz <- cbind(x,y,z)

xyz

Date: Sat 25 Feb 2006 - 04:23:36 EST

Henrik,

If I understand your question, what you want is:

x <- runif(9) y <- runif(9) z <- rep(c(0,1,2), each=3)

xyz <- cbind(x,y,z)

xyz

d.all <- dist(xyz[,c("x","y")])

d.all

xyz.02 <- subset(xyz, z == 0 | z == 2)

xyz.02

d.02 <- dist(xyz.02[,c("x","y")])

d.02

Marc

-----Original Message-----

From: r-help-bounces@stat.math.ethz.ch [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Henrik Parn
Sent: Thursday, February 23, 2006 8:40 AM
To: r-help@stat.math.ethz.ch

Subject: [R] dist() between groups of data

x <- runif(6) y <- runif(6) z <- rep(c(0,1), each=3)

xyz <- cbind(x,y,z)

xyz

x y z

[1,] 0.7176801 0.760944688 0

*[2,] 0.2377928 0.080622524 0
**[3,] 0.9450770 0.022039470 0
**[4,] 0.8725492 0.971996677 1
**[5,] 0.6356198 0.001569859 1
**[6,] 0.8949670 0.066044377 1
*

First of all, I suppose that this is the correct way to calculate the Euclidean distance between /all/ nests:

xy <- cbind(x,y)

d.all <- dist(xy)

However, I would like to obtain a distance matrix for distances between nests belonging to certain groups. For example "calculate all distances from nests where z equals something, to nests where z equals something else".

Is it best to split the data in two matrices according to the value of z in the two groups to be compared, and then try to follow the suggestions by Gabor Grothendieck* Date:* Wed 07 Jan 2004 - 15:16:37 EST , or are there other ways that can be applied straight to one matrix?

Thanks in advance!

Henrik

-- ************************ Henrik Pärn Department of Biology NTNU 7491 Trondheim Norway +47 735 96282 (office) +47 909 89 255 (mobile) +47 735 96100 (fax) ______________________________________________ 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 ______________________________________________ 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.htmlReceived on Sat Feb 25 04:33:40 2006

*
This archive was generated by hypermail 2.1.8
: Sat 25 Feb 2006 - 06:08:44 EST
*