Apply a function across a selection of columns
Apply a function across a selection of columns. For use in arrange.()
,
mutate.()
, and summarize.()
.
across.(.cols = everything(), .fns = NULL, ..., .names = NULL)
.cols |
vector |
.fns |
Functions to pass. Can pass a list of functions. |
... |
Other arguments for the passed function |
.names |
A glue specification that helps with renaming output columns.
|
test_df <- data.table( x = rep(1, 3), y = rep(2, 3), z = c("a", "a", "b") ) test_df %>% mutate.(across.(c(x, y), ~ .x * 2)) test_df %>% summarize.(across.(c(x, y), ~ mean(.x, na.rm = TRUE)), .by = z) test_df %>% arrange.(across.(c(y, z)))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.