title: Difference between .groups argument and ungroup() in dplyr?
body: <p>I'm looking at some code:</p>
  <pre><code>df1 &lt;- inner_join(metadata, otu_counts, by=&quot;sample_id&quot;) %&gt;%
    inner_join(., taxonomy, by=&quot;otu&quot;) %&gt;% 
    group_by(sample_id) %&gt;%
    mutate(rel_abund = count / sum(count)) %&gt;% 
    ungroup() %&gt;% 
    select(-count)
  </code></pre>
  <p>This first chunk I completely understand but I'm new and I can only assume that this second chunk's '.group = &quot;drop&quot;' does the same thing as the previous ungroup().</p>
  <p>If so, then does it have to do with the last function being a summarize() function?</p>
  <pre><code>df2 &lt;- df1 %&gt;%
    filter(level==&quot;phylum&quot;) %&gt;%
    group_by(disease_stat, sample_id, taxon) %&gt;%
    summarize(rel_abund = sum(rel_abund), .groups=&quot;drop&quot;) %&gt;% #
    group_by(disease_stat, taxon) %&gt;%
    summarize(mean_rel_abund = 100*mean(rel_abund), .groups=&quot;drop&quot;) 
  </code></pre>
  <p>Can someone explain?</p>
  <p>UPDATE: I realize that the first .groups = &quot;drop&quot; eliminates a newly created variable which was sample_id. Is there more to this?</p>