I'm trying to calculate the quintiles within each group of a dataframe. If I do:
mtcars %>%
group_by(gear,carb) %>%
summarise(total = sum(wt), .groups = "keep") %>%
mutate(rank = ntile(total,5))
All entries within the rank column are equal to 1. What am I doing wrong here?