title: How to sum values for each unique group in R
body: <p>In the dataset below, I want to identify <code>Top 3</code>  time-consuming projects</p>
  <pre><code>library(dplyr)
  TransID &lt;-c(1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1014,1018,1022,1023,1024)
  EmpID&lt;-c('M001','M001','M001','M001','B005','B005','B005','B005','X101','X101','X101','Z101','K501','K501','K501','K501')
  ProjectID &lt;- c(200,200,200,200,500,500,500,500,950,950,950,950,1050,1050,1050,1050)
  Site&lt;-c('X','X','X','Y','Y','Y','Z','Z','Z','G','G','G','G','K','K','K')
  Region &lt;-c('NE','NW','SE','SW','MW','NW','SW','NE','NC','MW','NE','SE','SW','NC','SW','SE')
  hour_difference&lt;-c(1.45,2.14,2.53,3.69,1.73,2.47,3.63,1.59,0.75,1.18,2.78,9.55,1.85,2.39,5.52,0.23)
  
  df = data.frame(TransID,EmpID,ProjectID,Site,Region,hour_difference)
  df
  </code></pre>
  <p>Simply,</p>
  <ol>
  <li>for each unique <code>ProjectID</code>, I want to sum the <code>hour_difference</code> and <code>sort</code> in descending order</li>
  </ol>
  <p>My attempt:</p>
  <pre><code>df %&gt;%
    group_by(ProjectID,hour_difference) %&gt;%
    summarize(sum().sort_values())
  
  </code></pre>
  <p>Desired output:</p>
  <p>for example, <code>ProjectID = 950</code> will have a sum of <code>14.26</code></p>