Last active
July 2, 2019 19:17
-
-
Save ramnathv/8d9e2f3f43741ad75b0a44798ce5d937 to your computer and use it in GitHub Desktop.
group_mean
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
#' Group Mean | |
#' | |
#' @examples | |
#' iris %>% | |
#' group_mean(Species, Petal.Length) | |
group_mean <- function(tbl, group_var, summary_var){ | |
tbl %>% | |
group_by({{ group_var }}) %>% | |
summarize( | |
{{ summary_var }} := mean({{ summary_var }}) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment