I\'m looking for a solution to add the column \"desired_result\" preferably using dplyr and/or ave(). See the data frame here, where the group is \"section\" and the unique
dense_rank it is
dense_rank
library(dplyr) df %>% group_by(section) %>% mutate(desire=dense_rank(exhibit)) # section exhibit desired_result desire #1 1 a 1 1 #2 1 b 2 2 #3 1 c 3 3 #4 1 c 3 3 #5 2 a 1 1 #6 2 b 2 2 #7 2 b 2 2 #8 2 c 3 3