> # Function to compute quantiles and return a data frame > g <- function(d) { > qq <- as.data.frame(as.list(quantile(d$y, c(.05, .25, .50, .75, .95)))) > names(qq) <- paste('Q', c(5, 25, 50, 75, 95), sep = '') > qq }
You could cut out the melt step by making this return a data frame: g <- function(df, qs = c(.05, .25, .50, .75, .95)) { data.frame(q = qs, quantile(d$y, qs)) } Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ ______________________________________________ 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.