Appendix E — Extras: Arranging rows in dplyr
E.1 Arranging the rows of your data by column
This is continued from ?sec-data-management.
You may want to sort your rows by a specific column so that values are arranged in ascending or descending order. This can be done using the function called arrange()
. Again, arrange()
takes the dataset as the first argument, followed by the columns that you wish to arrange data by. By default, arrange()
orders in ascending order.
arrange()
also arranges parameters of type character
alphabetically:
If we want to order the column based on descending order, this can be done with desc()
.
You can also order your data by multiple columns. For instance, we could arrange first by education
and then by age
.