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 ______________________________________________ R-help@r-project.org 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.