title: Add a new row to each dataframe in a list of a dataframes R
body: <p>I have a list of a dataframes, which I have calculated the colmeans for each column of each dataframe except columns 1 and 2 of the dataframes.  A small section of my list of dataframes is at the bottom.</p>
  <p>I calculated the colmeans with the line below</p>
  <pre><code>df_colmeans &lt;- lapply(df, function(x) colMeans(x[-c(1:2)],na.rm = T))
  </code></pre>
  <p>I want to add the colmeans back to each dataframe in my list of dataframes and tried the line below but ended up with a result that wasn't correct.</p>
  <pre><code>df &lt;- rbind(df[-c(1:2)],df_colmeans)
  
  </code></pre>
  <p>I get the following error</p>
  <p>In rbind(df[-c(1:2)], df_colmeans) :
  number of columns of result is not a multiple of vector length (arg 2)</p>
  <p>If there is a way to do it one step, without creating a separate variable (df_colmeans) that would be ideal.</p>
  <p>Any help and suggestions greatly appreciated.</p>
  <pre><code>list(Fe.II. = structure(list(Lab = c(&quot;AD&quot;, &quot;AD&quot;, &quot;AK&quot;, &quot;AK&quot;, 
  &quot;AO&quot;, &quot;AO&quot;, &quot;BQ&quot;, &quot;BQ&quot;, &quot;CI&quot;, &quot;CI&quot;, &quot;CL&quot;, &quot;CL&quot;, &quot;CP&quot;, &quot;CP&quot;, &quot;CU&quot;, 
  &quot;CU&quot;, &quot;CW&quot;, &quot;CW&quot;, &quot;CZ&quot;, &quot;CZ&quot;, &quot;DA&quot;, &quot;DA&quot;, &quot;DC&quot;, &quot;DC&quot;, &quot;DF&quot;, &quot;DF&quot;, 
  &quot;EQ&quot;, &quot;EQ&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;FL&quot;, &quot;FL&quot;, &quot;FM&quot;, &quot;FM&quot;, &quot;FO&quot;, &quot;FO&quot;, &quot;FP&quot;, 
  &quot;FP&quot;, &quot;FR&quot;, &quot;FR&quot;, &quot;GB&quot;, &quot;GB&quot;, &quot;GC&quot;, &quot;GC&quot;, &quot;GL&quot;, &quot;GL&quot;, &quot;GM&quot;, &quot;GM&quot;, 
  &quot;GT&quot;, &quot;GT&quot;, &quot;GY&quot;, &quot;GZ&quot;, &quot;I&quot;, &quot;I&quot;, &quot;K&quot;, &quot;K&quot;, &quot;M&quot;, &quot;M&quot;, &quot;Q&quot;, &quot;Q&quot;, 
  &quot;S&quot;, &quot;S&quot;, &quot;U&quot;, &quot;U&quot;, &quot;V&quot;, &quot;V&quot;, &quot;W&quot;, &quot;W&quot;), `Sample Prep` = c(335, 
  337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 
  335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 
  337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 
  335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 337, 337, 335, 
  337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 
  335, 337), `1` = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.19, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, 0.17, NA, 0.14, NA, NA, NA, NA, NA), `2` = c(NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, 0.01, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.13, NA, 0.15, NA, NA, 
  NA, NA, NA), `3` = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, 0.02, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, 0.23, NA, 0.29, NA, NA, NA, NA), `4` = c(NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.02, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.22, NA, 
  0.29, NA, NA, NA, NA)), class = &quot;data.frame&quot;, row.names = c(NA, 
  -68L)), SiO2 = structure(list(Lab = c(&quot;AD&quot;, &quot;AD&quot;, &quot;AK&quot;, &quot;AK&quot;, 
  &quot;AO&quot;, &quot;AO&quot;, &quot;BQ&quot;, &quot;BQ&quot;, &quot;CI&quot;, &quot;CI&quot;, &quot;CL&quot;, &quot;CL&quot;, &quot;CP&quot;, &quot;CP&quot;, &quot;CU&quot;, 
  &quot;CU&quot;, &quot;CW&quot;, &quot;CW&quot;, &quot;CZ&quot;, &quot;CZ&quot;, &quot;DA&quot;, &quot;DA&quot;, &quot;DC&quot;, &quot;DC&quot;, &quot;DF&quot;, &quot;DF&quot;, 
  &quot;EQ&quot;, &quot;EQ&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;FL&quot;, &quot;FL&quot;, &quot;FM&quot;, &quot;FM&quot;, &quot;FO&quot;, &quot;FO&quot;, &quot;FP&quot;, 
  &quot;FP&quot;, &quot;FR&quot;, &quot;FR&quot;, &quot;GB&quot;, &quot;GB&quot;, &quot;GC&quot;, &quot;GC&quot;, &quot;GL&quot;, &quot;GL&quot;, &quot;GM&quot;, &quot;GM&quot;, 
  &quot;GT&quot;, &quot;GT&quot;, &quot;GY&quot;, &quot;GZ&quot;, &quot;I&quot;, &quot;I&quot;, &quot;K&quot;, &quot;K&quot;, &quot;M&quot;, &quot;M&quot;, &quot;Q&quot;, &quot;Q&quot;, 
  &quot;S&quot;, &quot;S&quot;, &quot;U&quot;, &quot;U&quot;, &quot;V&quot;, &quot;V&quot;, &quot;W&quot;, &quot;W&quot;), `Sample Prep` = c(335, 
  337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 
  335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 
  337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 
  335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 337, 337, 335, 
  337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 
  335, 337), `1` = c(3.65, NA, 3.595, NA, 3.645, NA, 3.66, NA, 
  3.644, NA, 3.547, NA, 3.648, NA, 3.655, NA, NA, NA, 3.666, NA, 
  3.686, NA, 3.674, NA, 3.667, NA, 3.59, NA, 3.63, NA, 3.689, NA, 
  3.64, NA, 3.58, NA, NA, NA, 3.46, NA, 3.71, NA, 3.66, NA, 3.65, 
  NA, 3.64, NA, 3.503, NA, NA, NA, 3.631, NA, 3.731, NA, 3.656, 
  NA, NA, NA, 3.75, NA, 3.656, NA, 3.667, NA, 3.684, NA), `2` = c(3.6, 
  NA, 3.591, NA, 3.646, NA, 3.65, NA, 3.625, NA, 3.548, NA, 3.648, 
  NA, 3.643, NA, NA, NA, 3.679, NA, 3.69, NA, 3.646, NA, 3.577, 
  NA, 3.6, NA, 3.63, NA, 3.692, NA, 3.66, NA, 3.59, NA, NA, NA, 
  3.512, NA, 3.703, NA, 3.62, NA, 3.63, NA, 3.63, NA, 3.49, NA, 
  NA, NA, 3.627, NA, 3.739, NA, 3.669, NA, NA, NA, 3.73, NA, 3.66, 
  NA, 3.664, NA, 3.669, NA), `3` = c(NA, 3.55, NA, 3.662, NA, 3.665, 
  NA, 3.65, NA, 3.67, NA, 3.576, NA, 3.631, NA, 3.683, NA, NA, 
  NA, 3.638, NA, 3.703, NA, 3.666, NA, NA, NA, 3.59, NA, 3.61, 
  NA, 3.657, NA, 3.67, NA, NA, NA, NA, NA, 3.8, NA, 3.684, NA, 
  3.69, NA, 3.66, NA, 3.69, NA, 4.398, 3.672, NA, NA, 3.678, NA, 
  3.769, NA, 3.678, NA, 3.718, NA, 3.75, NA, 3.636, NA, NA, NA, 
  3.603), `4` = c(NA, 3.57, NA, 3.69, NA, 3.624, NA, 3.66, NA, 
  3.673, NA, 3.551, NA, 3.64, NA, 3.684, NA, NA, NA, 3.678, NA, 
  3.673, NA, 3.696, NA, NA, NA, 3.56, NA, 3.62, NA, 3.615, NA, 
  3.66, NA, NA, NA, NA, NA, 3.642, NA, 3.684, NA, 3.67, NA, 3.67, 
  NA, 3.67, NA, 4.38, 3.672, NA, NA, 3.68, NA, 3.757, NA, 3.673, 
  NA, 3.759, NA, 3.78, NA, 3.64, NA, NA, NA, 3.597)), class = &quot;data.frame&quot;, row.names = c(NA, 
  -68L)), CaO = structure(list(Lab = c(&quot;AD&quot;, &quot;AD&quot;, &quot;AK&quot;, &quot;AK&quot;, 
  &quot;AO&quot;, &quot;AO&quot;, &quot;BQ&quot;, &quot;BQ&quot;, &quot;CI&quot;, &quot;CI&quot;, &quot;CL&quot;, &quot;CL&quot;, &quot;CP&quot;, &quot;CP&quot;, &quot;CU&quot;, 
  &quot;CU&quot;, &quot;CW&quot;, &quot;CW&quot;, &quot;CZ&quot;, &quot;CZ&quot;, &quot;DA&quot;, &quot;DA&quot;, &quot;DC&quot;, &quot;DC&quot;, &quot;DF&quot;, &quot;DF&quot;, 
  &quot;EQ&quot;, &quot;EQ&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;FL&quot;, &quot;FL&quot;, &quot;FM&quot;, &quot;FM&quot;, &quot;FO&quot;, &quot;FO&quot;, &quot;FP&quot;, 
  &quot;FP&quot;, &quot;FR&quot;, &quot;FR&quot;, &quot;GB&quot;, &quot;GB&quot;, &quot;GC&quot;, &quot;GC&quot;, &quot;GL&quot;, &quot;GL&quot;, &quot;GM&quot;, &quot;GM&quot;, 
  &quot;GT&quot;, &quot;GT&quot;, &quot;GY&quot;, &quot;GZ&quot;, &quot;I&quot;, &quot;I&quot;, &quot;K&quot;, &quot;K&quot;, &quot;M&quot;, &quot;M&quot;, &quot;Q&quot;, &quot;Q&quot;, 
  &quot;S&quot;, &quot;S&quot;, &quot;U&quot;, &quot;U&quot;, &quot;V&quot;, &quot;V&quot;, &quot;W&quot;, &quot;W&quot;), `Sample Prep` = c(335, 
  337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 
  335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 
  337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 
  335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 337, 337, 335, 
  337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 335, 337, 
  335, 337), `1` = c(0.04, NA, NA, NA, 0.055, NA, 0.053, NA, 0.055, 
  NA, 0.021, NA, 0.049, NA, 0.052, NA, NA, NA, 0.053, NA, 0.056, 
  NA, 0.054, NA, 0.036, NA, 0.032, NA, 0.06, NA, 0.053, NA, 0.05, 
  NA, 0.043, NA, NA, NA, NA, NA, 0.054, NA, 0.057, NA, 0.052, NA, 
  0.05, NA, 0.048, NA, NA, NA, 0.056, NA, 0.043, NA, 0.053, NA, 
  NA, NA, 0.052, NA, 0.076, NA, 0.051, NA, 0.047, NA), `2` = c(0.04, 
  NA, NA, NA, 0.054, NA, 0.053, NA, 0.055, NA, 0.023, NA, 0.05, 
  NA, 0.05, NA, NA, NA, 0.051, NA, 0.053, NA, 0.056, NA, 0.036, 
  NA, 0.032, NA, 0.06, NA, 0.053, NA, 0.05, NA, 0.043, NA, NA, 
  NA, NA, NA, 0.056, NA, 0.056, NA, 0.057, NA, 0.05, NA, 0.05, 
  NA, NA, NA, 0.053, NA, 0.043, NA, 0.053, NA, NA, NA, 0.052, NA, 
  0.076, NA, 0.051, NA, 0.047, NA), `3` = c(NA, 0.04, NA, NA, NA, 
  0.055, NA, 0.053, NA, 0.057, NA, 0.023, NA, 0.05, NA, 0.055, 
  NA, NA, NA, 0.053, NA, 0.053, NA, 0.054, NA, NA, NA, 0.045, NA, 
  0.06, NA, 0.052, NA, 0.05, NA, NA, NA, NA, NA, 0.05, NA, 0.054, 
  NA, 0.056, NA, 0.054, NA, 0.05, NA, 0.054, 0.057, NA, NA, 0.057, 
  NA, 0.053, NA, 0.054, NA, 0.052, NA, 0.05, NA, 0.045, NA, NA, 
  NA, 0.051), `4` = c(NA, 0.04, NA, NA, NA, 0.054, NA, 0.053, NA, 
  0.056, NA, 0.019, NA, 0.052, NA, 0.056, NA, NA, NA, 0.051, NA, 
  0.051, NA, 0.056, NA, NA, NA, 0.047, NA, 0.06, NA, 0.046, NA, 
  0.05, NA, NA, NA, NA, NA, 0.05, NA, 0.054, NA, 0.055, NA, 0.054, 
  NA, 0.05, NA, 0.052, 0.056, NA, NA, 0.055, NA, 0.053, NA, 0.053, 
  NA, 0.051, NA, 0.052, NA, 0.046, NA, NA, NA, 0.051)), class = &quot;data.frame&quot;, row.names = c(NA, 
  -68L)))
  </code></pre>