title: R: Calculate mean by column in a list of dataframes using pipes %>% in dplyr
body: <p>I am trying to get better in using pipes <code>%&gt;%</code> in <code>dplyr</code> package. I understand that the whole point of using pipes (<code>%&gt;%</code>) is that it replaces the first argument in a function by the one connected by pipe. That is, in this example:</p>
  
  <pre><code>area = rep(c(3:7), 5) + rnorm(5)
  </code></pre>
  
  <p>Pipes</p>
  
  <pre><code>area %&gt;% 
    mean
  </code></pre>
  
  <p>equal normal function</p>
  
  <pre><code>`mean(area)`.
  </code></pre>
  
  <hr>
  
  <p>My problem is when it gets to a dataframe. I would like to split dataframe in a list of dataframes, and than calculate means per <code>area</code> columns. But, I can't figure out how to call the column instead of the dataframe?</p>
  
  <p>I know that I can get means by year simply by <code>aggregate(area~ year, df, mean)</code> but I would like to practice pipes instead.</p>
  
  <p>Thank you!</p>
  
  <hr>
  
  <pre><code># Dummy data
  set.seed(13)
  df&lt;-data.frame(year = rep(c(1:5), each = 5),
                 area = rep(c(3:7), each = 5) + rnorm(1))
  
  # Calculate means. 
  # Neither `mean(df$area)`, `mean("area")` or `mean[area]` does not work. How to call the column correctly?
  
  df %&gt;% 
    split(df$year) %&gt;%
    mean
  </code></pre>