Like this?
my.points<-data.frame(cbind(x=c(1,10,50,100,1,20,10,100),y=c(1,5,20,50,100,1,1,10)))
rownames(my.points)<-paste("pt",1:8,sep="")
plot(my.points)
text((my.points+2),rownames(my.points),col="red")
require(vegan)
my.points.dist<-vegdist(my.points,method="euclidean")
my.points.dist
kind regards,
miltinho
----- Mensagem original ----
De: WCD <[EMAIL PROTECTED]>
Para: [email protected]
Enviadas: Domingo, 20 de Janeiro de 2008 17:41:45
Assunto: [R] distance matrix
Hello, I want do get the point to point distance matrix.
Suppose, I have a data frame where the first column is X and second column
is Y coordinate of points.
I define a function dst(x1,y1,x2,y2) to claculate distance between two
points. But I don't know how to tell R to calculate dst for every two points
and create a matrix of these distances.
Can you give me a little guidance, please? I am quite new to R and
programming.
Thanks for every advice. Filip Kral.
--
View this message in context:
http://www.nabble.com/distance-matrix-tp14986595p14986595.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
[email protected] 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.
para armazenamento!
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.