df <- data.table(
x = rep(1, 3),
y = rep(2, 3),
z = c("a", "a", "b")
)
df %>%
mutate_across.(where(is.numeric), as.character)
df %>%
mutate_across.(c(x, y), ~ .x * 2)
df %>%
mutate_across.(everything(), as.character)
df %>%
mutate_across.(c(x, y), list(new = ~ .x * 2,
another = ~ .x + 7))
df %>%
mutate_across.(
.cols = c(x, y),
.fns = list(new = ~ .x * 2, another = ~ .x + 7),
.names = "{.col}_test_{.fn}"
)
Run the code above in your browser using DataLab