Re: [R] r function for calculating extreme spread in group

2008-08-27 Thread Jorge Ivan Velez
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 Mat

Re: [R] r function for calculating extreme spread in group

2008-08-27 Thread Dylan Beaudette
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 >

Re: [R] r function for calculating extreme spread in group

2008-08-27 Thread Steven Matthew Anderson
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 =as.data.frame(cbind(lvl=LE

Re: [R] r function for calculating extreme spread in group

2008-08-27 Thread Ben Bolker
Steven Matthew Anderson 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