title: How to average every two rows of dataframe in R
body: <p>I have the following data frame (with 1000's of columns):</p>
  
  <pre><code>df&lt;- structure(c(1, 2, 2, 1, 2, 2, 2, 1, 3, 3, 2, 2), 
                .Dim = 4:3, .Dimnames = list(c("a", "b", "c", "d"), 
                 c("t1", "t2", "t3")))
  </code></pre>
  
  <p>What would be an efficient way to get average of every two rows?</p>
  
  <p>Result I want:</p>
  
  <pre><code>     t1 t2 t3
  a    1  2  3
  b    2  2  3
  a_b  1.5 2 3
  c    2  2  2
  d    1  1  2
  c_d  1.5 1.5 2
  </code></pre>