I'm looking to create a new column which is based on the ordering of two other columns, preferably using the Tidyverse functions, but any suggestions are appreciated. I have a table of around 1300 entries and several columns but a sample of my data looks something like:
Number of people | TotalOrder | TotalQuantile |
---|---|---|
12 | 1 | 1 |
19 | 2 | 1 |
21 | 3 | 2 |
45 | 5 | 2 |
53 | 5 | 3 |
55 | 6 | 3 |
60 | 7 | 4 |
75 | 8 | 4 |
But I want a fourth column which ranks TotalOrder within TotalQuantile, and to look something like:
Number of people | TotalOrder | TotalQuantile | NewOrder |
---|---|---|---|
12 | 1 | 1 | 1 |
19 | 2 | 1 | 2 |
21 | 3 | 2 | 1 |
45 | 5 | 2 | 2 |
53 | 5 | 3 | 1 |
55 | 6 | 3 | 2 |
60 | 7 | 4 | 1 |
75 | 8 | 4 | 2 |
I've tried a few things like filtering, arranging, etc but it's not worked out. Thanks for the help.