funs() provides a flexible way to generate a named list of functions for input to other functions like summarise_at().

funs(..., .args = list())

Arguments

...

A list of functions specified by:

  • Their name, "mean"

  • The function itself, mean

  • A call to the function with . as a dummy argument, mean(., na.rm = TRUE)

These arguments are automatically quoted. They support unquoting and splicing. See vignette("programming") for an introduction to these concepts.

.args, args

A named list of additional arguments to be added to all function calls.

Examples

funs(mean, "mean", mean(., na.rm = TRUE))
#> <fun_calls> #> $ mean: mean(.) #> $ mean: mean(.) #> $ mean: mean(., na.rm = TRUE)
# Override default names funs(m1 = mean, m2 = "mean", m3 = mean(., na.rm = TRUE))
#> <fun_calls> #> $ m1: mean(.) #> $ m2: mean(.) #> $ m3: mean(., na.rm = TRUE)
# If you have function names in a vector, use funs_ fs <- c("min", "max") funs_(fs)
#> <fun_calls> #> $ min: min(.) #> $ max: max(.)