Re: [R] Partial aggregate on sorted data

2007-10-24 Thread Yves Moisan
>why not: >aggregate(myDataframe$TargetValue,list(SomeFactor = myDataframe$SomeFactor),function(x) mean(x[x>quantile(x,.66)])) Great stuff. Just what I was looking for ! Thanx a lot !! -- View this message in context: http://www.nabble.com/Partial-aggregate-on-sorted-data-tf4683988.html#a13

Re: [R] Partial aggregate on sorted data

2007-10-24 Thread kees
Yves, why not: aggregate(myDataframe$TargetValue,list(SomeFactor = myDataframe$SomeFactor),function(x) mean(x[x>quantile(x,.66)])) Op Wed, 24 Oct 2007 15:30:10 +0200 schreef Yves Moisan <[EMAIL PROTECTED]>: > > Hi All, > > I'm looking for ways to compute aggregate statistics (with the aggre

Re: [R] Partial aggregate on sorted data

2007-10-24 Thread Moisan Yves
- De : jim holtman [mailto:[EMAIL PROTECTED] Envoyé : 24 octobre 2007 09:48 À : Moisan Yves Cc : r-help@r-project.org Objet : Re: [R] Partial aggregate on sorted data Is this something like you want: > set.seed(1) > test <- data.frame(value=runif(100), fact=sample(LETTERS[1:5], 100, TRUE))

Re: [R] Partial aggregate on sorted data

2007-10-24 Thread jim holtman
Is this something like you want: > set.seed(1) > test <- data.frame(value=runif(100), fact=sample(LETTERS[1:5], 100, TRUE)) > result <- tapply(test$value, test$fact, function(x, sort, subset){ + x <- x[order(x, decreasing=(sort == "DECENDING"))] + mean(head(x, length(x) * subset)) + }, sor

[R] Partial aggregate on sorted data

2007-10-24 Thread Yves Moisan
Hi All, I'm looking for ways to compute aggregate statistics (with the aggregate function) but with an option for sorting and selecting a subset of the data frame. For example, I have would like to turn this : aggregate(myDataframe$TargetValue,list(SomeFactor = myDataframe$SomeFactor),mean) in