This function combines vars in vars (from left to right)
possibly scaling each variable individually prior to combining
Arguments
- df
data.frame containing
vars- vars
Vector of variable names to be combined into one
- name
Name of the new variable to be added to df
- scale
(logical) Whether to scale each variable prior to combining
Examples
df <- df |> scale_and_combine(c("x1", "x2", "x3"), name="x", scale=TRUE)
#> [1] "Added var x"