title: How do I add summary-statistics values to each row of a data frame?
body: <p>I would like to know a tidyverse way to add summary statistics back to each row of a dataframe.</p>
  
  <p>The code below works, but should be a quicker way out there, right?</p>
  
  <pre><code>library("tidyverse")
  data &lt;- (iris)
  
  means &lt;- iris %&gt;%
    group_by(Species) %&gt;%
    summarise(
      Sepal.Length = mean(Sepal.Length),
      Sepal.Width = mean(Sepal.Width)
    )
  
  data &lt;- merge(data, means, by = "Species")
  </code></pre>