title: Creating variable with means of multiple other variables in R
body: <p>How do I combine the means of multiple columns efficiently? I would like to create one object that has a list of means for variables beginning with A and a separate object that has a list of means for variables beginning with C. Ideally, I would be able to use column numbers as opposed to variable names since column numbers are easier to type.</p>
  
  <pre><code>A1U_sweet  A2F_dip  A3U_bbq  C1U_sweet  C2F_dip  C3U_bbq
  1          2        1        NA         NA       NA
  NA         NA       NA       4          1        2
  2          4        7        NA         NA       NA
  </code></pre>
  
  <p>I have used the following function in the past, but it is inefficient. I have many more columns than depicted here. I am including this to clarify what I am trying to do.</p>
  
  <pre><code>average_A&lt;-data.frame((mean(A1U_sweet, na.rm = TRUE)), (mean(A2F_dip, na.rm = TRUE)), (mean(A3U_bbq, na.rm = TRUE)))
  average_C&lt;-data.frame((mean(C1U_sweet, na.rm = TRUE)), (mean(C2F_dip, na.rm = TRUE)), (mean(C3U_bbq, na.rm = TRUE)))
  </code></pre>