Ranking functions number rows by a value. They differ only in how they treat ties:
row_number() gives every row its own number, so two equal values get 1 and 2 in whatever order the rows happen to be.
min_rank() gives ties the same rank and skips the next ones: 1, 2, 2, 4, the way sports tables do.
dense_rank() gives ties the same rank without gaps: 1, 2, 2, 3, for tiers and bands.
They rank from smallest to largest; wrap the column in desc() so the largest is 1. Add .by to rank within each group.
To keep the top rows of each group, slice_max(x, n = 1, by = group) is shorter than ranking and filtering. It keeps ties by default, so a group can return two rows; with_ties = FALSE keeps exactly n. Decide which one the question needs.
Three ways to rank the same tie, and the top row per group.