The desc() function can be used with the arrange() function to arrange a variable in a data frame in descending order.
Example 1:
For instance, when we use the arrange() function to sort the Fingers data frame by Thumb, it will sort the values for Thumb in ascending order (smallest to largest) by default, like so:
# arrange Thumb in ascending order
arrange(Fingers, Thumb)
Example of output from running the code above:
Example 2:
But if we want the values to be sorted in descending order (largest to smallest) we can include the desc() function in the argument for arrange(), like so: