title: R summarize dataframe depending on group/subgoup
body: <p>I am stuck here with another R-problem. I have a data frame of the following layout with over 2000 observations and 50 columns:</p>
  
  <pre><code>group &lt;- c("X","X","X","X","Y","Y","Y","Y","Z","Z","Z","Z")
  subgroup &lt;- c("A","B","A","B","A","B","A","B","A","B","A","B")
  obs1 &lt;- c(rnorm(12,mean=10))
  obs2 &lt;- c(rnorm(12,mean=20))
  e &lt;- data.frame(group,subgroup,obs1,obs2)
  </code></pre>
  
  <p>What I would like to have is a dataframe showing the sum of all observations for a specific group x subgroup interaction like this:
  column1=group column2=subgroup column2=sum of obs1, column4=sum obs2 ....</p>
  
  <p>group,subgroup and column labels should be preserved. 
  I tried: </p>
  
  <pre><code>for(i in levels(e$group)){test[i,]&lt;-as.matrix(Matrix::colSums(e[,3:4]))}
  </code></pre>
  
  <p>but this leads to an error. Probably you notice that I am not advanced with R coding :)</p>