Created
January 11, 2017 05:32
-
-
Save Keiku/9bfc499b700f5a0fab2d574369934095 to your computer and use it in GitHub Desktop.
Calculate frequency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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