[R] Question about ggplot2 and stat_smooth
Hadley Wickham
hadley at rice.edu
Tue Oct 4 21:10:47 CEST 2011
> # 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/
More information about the R-help
mailing list