Skip to content
Prev 201261 / 398503 Next

Odp: FUN argument to return a vector in aggregate function

Hi

r-help-bounces at r-project.org napsal dne 23.11.2009 09:15:02:
above.


It is work for sapply/split.

sapply(split(warpbreaks$breaks, warpbreaks[,-1]), function(x) c(mean(x), 
sum(x), length(x)))
           A.L       B.L A.M       B.M       A.H       B.H
[1,]  44.55556  28.22222  24  28.77778  24.55556  18.77778
[2,] 401.00000 254.00000 216 259.00000 221.00000 169.00000
[3,]   9.00000   9.00000   9   9.00000   9.00000   9.00000
Regards
Petr
http://www.R-project.org/posting-guide.html