Skip to content

Instantly share code, notes, and snippets.

@ramnathv

ramnathv/group_mean.R

Last active Jul 2, 2019
Embed
What would you like to do?
group_mean
#' 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
You can’t perform that action at this time.