title: Explain ungroup() in dplyr
body: <p>If I'm working with a dataset and I want to group the data (i.e. by <code>country</code>), compute a summary statistic (<code>mean()</code>) and then <code>ungroup()</code> the <code>data.frame</code> to have a dataset with the original dimensions (<code>country</code>-<code>year</code>) and a new column that lists the mean for each country (repeated over n years), how would I do that with <code>dplyr</code>?  The <code>ungroup()</code> function doesn't return a <code>data.frame</code> with the original dimensions:</p>
  
  <pre><code>gapminder %&gt;%
      group_by(country) %&gt;%
      summarize(mn = mean(pop)) %&gt;%
      ungroup() # returns data.frame with nrows == length(unique(gapminder$country))
  </code></pre>