Skip to contents

Standardize selected variables in a data frame or similar object.

Usage

std_data(data, to_standardize)

Arguments

data

A data frame or similar object.

to_standardize

A character vector of the column names of variables to be standardized.

Value

A data frame similar to data, with selected variables standardized.

Details

This is a helper functions to be used by lm_betaselect() and glm_betaselect(). It assumes that the variables selected has been checked whether they are numeric.

Examples


data(data_test_mod_cat)
dat <- data_test_mod_cat
dat <- std_data(dat, to_standardize = c("iv", "dv"))
colMeans(dat[, c("dv", "iv")])
#>           dv           iv 
#> 2.078719e-16 4.026692e-16 
apply(dat[, c("dv", "iv")], 2, sd)
#> dv iv 
#>  1  1