# NOT RUN {
test_df <- data.table(a = 1:3,
b = 4:6,
z = c("a", "a", "b"))
# Single function
test_df %>%
summarize_across.(c(a, b), mean, na.rm = TRUE)
# Single function using purrr style interface
test_df %>%
summarize_across.(c(a, b), ~ mean(.x, na.rm = TRUE))
# Passing a list of functions (with by)
test_df %>%
summarize_across.(c(a, b), list(mean, max), by = z)
# Passing a named list of functions (with by)
test_df %>%
summarize_across.(c(a, b),
list(avg = mean,
max_plus_one = ~ max(.x) + 1),
by = z)
# }
Run the code above in your browser using DataLab