title: Create multiple columns in summarize
body: <p>What is the best way to create multiple columns in <code>summarize(...)</code> (or, alternatively, in <code>do(...)</code>)?  This arises if some aggregation function returns more than one value.  An example of such a function is <code>quantile(...)</code>.</p>
  
  <p>For example, suppose we have the following data</p>
  
  <pre><code>library(dplyr)
  
  data.frame(x = runif(1000, min = 0, max = 20)) %&gt;%
    mutate(y = rnorm(n(), mean = sin(x))) %&gt;%
    group_by(x.category = round(x)) -&gt;
    Z
  </code></pre>
  
  <p>We can compute (and plot) quantiles easily:</p>
  
  <pre><code>library(ggplot2) # just to display results (not the focus of this question)
  
  Z %&gt;%
    summarize(x = mean(x),
              y25 = quantile(y, probs = .25),
              y50 = quantile(y, probs = .5),
              y75 = quantile(y, probs = .75)) %&gt;%
    gather(Statistic, y, -x, -x.category) %&gt;%
    ggplot(aes(x, y, color = Statistic)) +
    geom_line()
  </code></pre>
  
  <p>However, the above code has two shortcomings: 1) the <code>quantile(...)</code> code must be duplicated (this would become more tedious if, say, a dozen quantiles were needed), and 2) the column names (y25, y50, y75) might not match the actual quantiles.</p>
  
  <p>These problems can be fixed by leveraging the ability of <code>quantile(...)</code> to compute multiple quantiles and return them in a vector with names, as follows:</p>
  
  <pre><code>Z %&gt;%
    do(as_data_frame(c(x = mean(.$x),
                       as.list(quantile(.$y, probs = c(.25,.5,.75)))))) %&gt;%
    gather(Statistic, y, -x, -x.category) %&gt;%
    ggplot(aes(x, y, color = Statistic)) +
    geom_line()
  </code></pre>
  
  <p>However the above code seems ugly to me; in particular it requires <code>as.list(...)</code>, <code>c(...)</code>, <code>as_data_frame(...)</code>, and <code>do(...)</code> in order to do something pretty simple.</p>
  
  <p>Is there a better way?</p>