[R-sig-Geo] inter-point distance calcs
Jim Bouldin
jrbouldin at ucdavis.edu
Mon Aug 10 19:48:27 CEST 2009
Good grief, yes dist() will do quite nicely. Pardon the more or less
continuous brain lock while I learn R. Thanks.
Jim
> On Monday 10 August 2009, Jim Bouldin wrote:
> > Can anyone recommend a package that can calculate the distances between
> > points (either all or a defined sample of) for x,y point locations
> listed
> > in long format? Thanks in advance.
> >
>
> 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
>
>
> Cheers,
> Dylan
>
>
> --
> Dylan Beaudette
> Soil Resource Laboratory
> http://casoilresource.lawr.ucdavis.edu/
> University of California at Davis
> 530.754.7341
>
Jim Bouldin, PhD
Research Ecologist
Department of Plant Sciences, UC Davis
Davis CA, 95616
530-554-1740
More information about the R-sig-Geo
mailing list