# NOT RUN {
# Don't regress on any variable
simulated_data %>%
nc_standardize(starts_with("metabolite_"))
# Extract residuals by regressing on a variable
simulated_data %>%
nc_standardize(starts_with("metabolite_"), "age")
# Works with factors too
simulated_data %>%
dplyr::mutate(Sex = as.factor(sample(rep(c("F", "M"), times = nrow(.) / 2)))) %>%
nc_standardize(starts_with("metabolite_"), c("age", "Sex"))
# }
Run the code above in your browser using DataLab