Vectorized standardization function for use with dplyr mutate and across. For group-wise standardization, use dplyr::group_by() before mutate().
Examples
if (FALSE) { # \dontrun{
library(dplyr)
# Single variable
mtcars %>% mutate(mpg_z = standardize_vec(mpg))
# Multiple variables
mtcars %>% mutate(across(c(mpg, hp, wt), standardize_vec, .names = "{.col}_z"))
# Group-wise standardization
mtcars %>% group_by(cyl) %>% mutate(mpg_z = standardize_vec(mpg))
} # }