title: How to reverse the order of values in one column in a dataframe grouped by another column?
body: <p>Given the following toy data frame:</p>
  
  <pre><code>df &lt;- data.frame(A = c("A", "A", "A", "B", "B", "C", "C", "C", "C", "C"),
                   B = c(1, 2, 3, 1, 2, 1, 2, 3, 4, 5))
  </code></pre>
  
  <p>This data frame consists of 2 columns of which both columns are sorted ascending. </p>
  
  <p>The desired result is the same data frame, but with reversed values for column 'B' for each group specified by the values in column 'A':</p>
  
  <pre><code>&gt; df
     A B
  1  A 3
  2  A 2
  3  A 1
  4  B 2
  5  B 1
  6  C 5
  7  C 4
  8  C 3
  9  C 2
  10 C 1 
  </code></pre>