df <- data.table(
x = rep(1, 3),
y = rep(2, 3),
z = c("a", "a", "b")
)
df %>%
mutate(across(c(x, y), ~ .x * 2))
df %>%
summarize(across(where(is.numeric), ~ mean(.x)),
.by = z)
df %>%
arrange(across(c(y, z)))
Run the code above in your browser using DataLab