i use tapply and by often, but i always end up banging my head against the wall with the output.
is there a simpler way to convert the output of the following tapply to a dataframe or matrix than what i have here: # setup data for tapply dt = data.frame(bucket=rep(1:4,25),val=rnorm(100)) fn = function(x) { ret = c(unname(quantile(x,probs=seq(.25,.75,.25),na.rm=T)),mean(x,na.rm=T)) } a = tapply(dt$val,dt$bucket,fn) # i seem to be doing way more work than i should here.... n = names(a) mat = NULL for (i in 1:length(n)) { mat = rbind(mat,unname(unlist(a[i]))) } row.names(mat) = n thank you! ______________________________________________ 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.