title: Aggregate variables separetly in R [lapply + aggregate]
body: <p>I have a <code>data.frame</code> with a set of records and as variables different measurements. I would like to create a new <code>data.frame</code> containing the amount of records having a specific measurement value for each measurement. Basically what I am trying to do is: </p>
  
  <pre><code>record &lt;- c("r1", "r2", "r3") 
  firstMeasurement &lt;- c(15, 10, 10) 
  secondMeasurement &lt;- c(2, 4, 2) 
  df &lt;- data.frame(record, firstMeasurement, secondMeasurement)
  
  measurements &lt;- c(colnames(df[2:3]))
  measuramentsAggregate &lt;- lapply(measurements, function(i) 
                    aggregate(record~i, df, FUN=length))
  </code></pre>
  
  <p>I am getting really funny errors and I don't understand why. Can anyone help me?</p>
  
  <p>Many thanks!</p>