Created
September 30, 2019 16:03
-
-
Save dwhdai/c743609dc48382bc858d6f37296bd4e0 to your computer and use it in GitHub Desktop.
Group percentage of categorical variable
This file contains 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
percent <- function(data, group){ | |
group <- enquo(group) | |
data %>% | |
group_by(!!group) %>% | |
summarise(percentage = n()/nrow(data)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment