title: Taking column mean over a list of data frames in R
body: <p>Here's what I'm trying to do. My data frame has a factor variable, "country", and I want to split the data frame based on country. Then, I want to take the column mean over every variable for every country's data frame. </p>
  
  <p>Data here: <a href="https://github.com/pourque/country-data" rel="nofollow noreferrer">https://github.com/pourque/country-data</a></p>
  
  <p>I've done this so far...</p>
  
  <pre><code>myList &lt;- split(df1, df1$country)
  for(i in 1:length(myList)) {
  aggregate &lt;- mapply(myList[[i]][,-c(38:39)], colMeans)
  }
  </code></pre>
  
  <p>(I'm not including the 38th and 39th columns because those are factors.)</p>
  
  <p>I've read this (<a href="https://stackoverflow.com/questions/11051087/function-over-more-than-one-list">function over more than one list</a>) , which makes me think mapply is the answer here...but I'm getting this error: </p>
  
  <pre><code>Error in match.fun(FUN) : 
  'myList[[i]][, -c(38:39)]' is not a function, character or symbol 
  </code></pre>
  
  <p>Maybe I'm formatting it incorrectly?</p>