library(dplyr)
data(survey_data)
# Standard z-scores
data <- std(survey_data, age, income, suffix = "_z")
# Gelman 2-SD standardization (for regression)
data <- std(survey_data, income, age, method = "2sd",
suffix = "_z")
# Robust standardization
data <- std(survey_data, income, method = "mad", suffix = "_z")
# Weighted standardization
data <- std(survey_data, income, age,
weights = sampling_weight, suffix = "_z")
# Group-wise standardization
data <- survey_data %>%
group_by(region) %>%
std(income, suffix = "_z")
Run the code above in your browser using DataLab