title: R data frame rank by groups (group by rank) with package dplyr
body: <p>I have a data frame 'test' that look like this:</p>
  
  <pre><code>    session_id  seller_feedback_score
  1   1   282470
  2   1   275258
  3   1   275258
  4   1   275258
  5   1   37831
  6   1   282470
  7   1   26
  8   1   138351
  9   1   321350
  10  1   841
  11  1   138351
  12  1   17263
  13  1   282470
  14  1   396900
  15  1   282470
  16  1   282470
  17  1   321350
  18  1   321350
  19  1   321350
  20  1   0
  21  1   1596
  22  7   282505
  23  7   275283
  24  7   275283
  25  7   275283
  26  7   37834
  27  7   282505
  28  7   26
  29  7   138359
  30  7   321360
  </code></pre>
  
  <p>and a code (using package dplyr) that apparently should rank the 'seller_feedback_score' within each group of session_id:</p>
  
  <pre><code> test &lt;- test %&gt;% group_by(session_id) %&gt;% 
    mutate(seller_feedback_score_rank = dense_rank(-seller_feedback_score))
  </code></pre>
  
  <p>however, what is really happening is that R rank the entire data frame together without relating to the groups (session_id's):</p>
  
  <pre><code>session_id  seller_feedback_score   seller_feedback_score_rank_2
  1   1   282470  5
  2   1   275258  7
  3   1   275258  7
  4   1   275258  7
  5   1   37831   11
  6   1   282470  5
  7   1   26  15
  8   1   138351  9
  9   1   321350  3
  10  1   841 14
  11  1   138351  9
  12  1   17263   12
  13  1   282470  5
  14  1   396900  1
  15  1   282470  5
  16  1   282470  5
  17  1   321350  3
  18  1   321350  3
  19  1   321350  3
  20  1   0   16
  21  1   1596    13
  22  7   282505  4
  23  7   275283  6
  24  7   275283  6
  25  7   275283  6
  26  7   37834   10
  27  7   282505  4
  28  7   26  15
  29  7   138359  8
  30  7   321360  2 
  </code></pre>
  
  <p>I checked this by counting the unique 'seller_feedback_score_rank' values and not surprisingly it equals to the highest rank value. I'd appreciate if someone could reproduce and help. thanks</p>
  
  <p>link to my original question: <a href="https://stackoverflow.com/questions/27923279/r-group-by-and-aggregate-return-relative-rank-within-groups-using-plyr">R group by and aggregate - return relative rank within groups using plyr</a></p>