Learn R Programming

vectra (version 0.6.2)

across: Apply a function across multiple columns

Description

Used inside mutate() or summarise() to apply a function to multiple columns selected with tidyselect. Returns a named list of expressions.

Usage

across(.cols, .fns, ..., .names = NULL)

Value

A named list used internally by mutate/summarise.

Arguments

.cols

Column selection (tidyselect).

.fns

A function, formula, or named list of functions.

...

Additional arguments passed to .fns.

.names

A glue-style naming pattern. Uses {.col} and {.fn}. Default: "{.col}" if .fns is a single function, "{.col}_{.fn}" if .fns is a named list.

Examples

Run this code
f <- tempfile(fileext = ".vtr")
write_vtr(mtcars, f)
# In summarise (conceptual; across is expanded to individual expressions)
unlink(f)

Run the code above in your browser using DataLab