[R] r function for calculating extreme spread in group
Ben Bolker
bolker at ufl.edu
Thu Aug 28 00:30:44 CEST 2008
Steven Matthew Anderson <adastra69 <at> mac.com> writes:
> I'm trying to figure out how to write a r function that will calculate
> the extreme spread of a group of points given their (x,y)
> coordinates. Extreme Spread is the maximal Euclidean distance between
> two points in a group
>
> ex.spread = max{ sqrt [ (xi-xj)^2 - (yi-yj)^2 ] } for i not equal to j
>
> I have 60 levels to apply this to.
>
how about something like
max(dist(cbind(x,y)) ... ???
(or to do this in a data frame d with columns x, y, and g (group),
sapply(split(d,d$g),function(Z)max(dist(Z[,c("x","y")])))
Ben Bolker
More information about the R-help
mailing list