Skip to content

Instantly share code, notes, and snippets.

@ctufts
Last active June 24, 2016 14:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ctufts/68765a4ff09d34157fb222a28bab9852 to your computer and use it in GitHub Desktop.
Group by , summarise, sort on summary data, append ranking from the sorting - dplyr
ds %>% group_by(group1, group2) %>%
summarise(
summary_value = some_function
) %>% arrange(desc(summary_value)) %>% group_by(group1) %>%
mutate(rank=row_number())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment