Skip to content

Instantly share code, notes, and snippets.

@Keiku

Keiku/freq.r

Created Jan 11, 2017
Embed
What would you like to do?
Calculate frequency.
freq <- function(df, ...){
df %<>%
group_by_(...) %>%
summarise(count = n()) %>%
arrange_(.dots = ...) %>%
ungroup() %>%
mutate(
cum_count = cumsum(count),
percent = count / sum(count),
cum_percent = cumsum(percent)
)
return(df)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.