title: Sum of column values based on other columns in R
body: <p>I am relatively new to R,trying to get sum of column based on other columns .my data frame is like below</p>
  
  <pre><code>YEAR EventID LOSS
      1     554  334740
      1     415  149816
      1     207  199446
      2     961  527042
      3     614  188199
      4     968   87044
      4     650   75377
      4     341  424678
      4     397  210730
      5     610  368068
  </code></pre>
  
  <p>Here my condition is , I need the sum of HIGHEST loss by each year.</p>
  
  <p>loss numbers of : EVENTID 554 from YEAR 1,EVENTID 961 from YEAR 2, EVENTID 341 from 4, EVENTID 610 from YEAR 5.</p>