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
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
Thank you Jorge,
My talent in building functions is weak. I think I'm close but I'm
not doing something right.
res=dist(yourdata)
res[which.max(res)]
does provide me with the correct distance but how do I apply it across
data with level such as ...
yourdata
On Wednesday 27 August 2008, Steven Matthew Anderson wrote:
Thank you Jorge,
My talent in building functions is weak. I think I'm close but I'm
not doing something right.
res=dist(yourdata)
res[which.max(res)]
does provide me with the correct distance but how do I apply it across
data
Dear Steven,
Try this:
# Data set
yourdata=as.data.frame(cbind(lvl=LETTERS[1:2],x=rpois(10,10),y=rnorm(10) ))
# Splitting your data set
sdata=split(yourdata,yourdata$lvl)
res=lapply(sdata,function(X) max(dist(X[,-1])))
do.call(c,res)
HTH,
Jorge
On Wed, Aug 27, 2008 at 7:28 PM, Steven
5 matches
Mail list logo