[R-sig-Geo] inter-point distance calcs

Jim Bouldin jrbouldin at ucdavis.edu
Mon Aug 10 20:39:35 CEST 2009


> Sure. How about the function dist():
> 
> d <- data.frame(x=sample(1:10, 5), y=sample(1:10, 5))
> 
> dist(d)
>          1        2        3        4
> 2 3.605551                           
> 3 6.403124 7.071068                  
> 4 9.219544 7.211103 5.830952         
> 5 8.062258 5.099020 7.211103 3.162278

Actually I spoke a bit too soon--I need to get the distances into the
following format (using your example above):

Point Pair      Distance
1-2             3.6 
1-3             6.4
1-4             9.2
.               etc



More information about the R-sig-Geo mailing list