title: how to average groups of elements in a list in R?
body: <p>In R, I have list of 10 elements,such as:</p>
  
  <pre><code>n &lt;- c(5,5,5,5,5,6,6,6,6,6)
  </code></pre>
  
  <p>I want to create another list which will have 2 elements where each element will be the average of 5-elements in the previous list. So, other list should look like as follows:</p>
  
  <pre><code>5,6
  </code></pre>
  
  <p>Is there a quick way to do that in R? What i want is a list which gives me the average of first X element, the average of second X element and so on.. In the example, initial list has 10 elements and I want to group them by 5. So I am trying to calculate a list where first element is the mean of first 5 elements, and the second element is the mean of last 5 elements.</p>