title: Summarize data at different aggregate levels - R and tidyverse
body: <p>I'm creating a bunch of basic status reports and one of things I'm finding tedious is adding a total row to all my tables. I'm currently using the Tidyverse approach and this is an example of my current code. What I'm looking for is an option to have a few different levels included by default.</p>
  
  <pre><code>#load into RStudio viewer (not required)
  iris = iris
  
  #summary at the group level
  summary_grouped = iris %&gt;% 
         group_by(Species) %&gt;%
         summarize(mean_s_length = mean(Sepal.Length),
                   max_s_width = max(Sepal.Width))
  
  #summary at the overall level
  summary_overall = iris %&gt;% 
    summarize(mean_s_length = mean(Sepal.Length),
              max_s_width = max(Sepal.Width)) %&gt;%
    mutate(Species = "Overall")
  
  #append results for report       
  summary_table = rbind(summary_grouped, summary_overall)
  </code></pre>
  
  <p>Doing this multiple times over is very tedious. I kind of want:</p>
  
  <pre><code>summary_overall = iris %&gt;% 
         group_by(Species, total = TRUE) %&gt;%
         summarize(mean_s_length = mean(Sepal.Length),
                   max_s_width = max(Sepal.Width))
  </code></pre>
  
  <p>FYI - if you're familiar with SAS I'm looking for the same type of functionality available via a class, ways or types statements in proc means that let me control the level of summarization and get multiple levels in one call.</p>
  
  <p>Any help is appreciated. I know I can create my own function, but was hoping there is something that already exists. I would also prefer to stick with the tidyverse style of programming though I'm not set on that.</p>