title: Performing calculations by level in R
body: <p>I'm trying to perform calculations based off a certain level in my data frame.</p>
  
  <pre><code>YEAR    MONTH   CARRIER ORIGIN  DEST    DEP_DELAY   ARR_DELAY   CANCELLED   
  1   2014    1   AA  JFK LAX 14  13  0
  2   2014    1   AA  JFK LAX -3  1   0   
  3   2014    1   AA  JFK LAX NA  NA  1   
  4   2014    1   AA  JFK LAX 65  59  0   
  5   2014    1   AA  JFK LAX 110 110 0   
  6   2014    1   AA  JFK LAX 17  -8  0   
  7   2014    1   AA  JFK LAX 10  -13 0   
  </code></pre>
  
  <p>For example, I want to group by <code>$CARRIER</code> and find out how many times each carrier had a flight delay. I also want to calculate other things, like mean arrival delays, etc.
  Can anyone show me how to perform calculations by level in R?
  Thanks!
  Hannah</p>