data(vi_smol)
## OPTIONAL: parallelization setup
## irrelevant when all predictors are numeric
## only worth it for large data with many categoricals
# future::plan(
# future::multisession,
# workers = future::availableCores() - 1
# )
## OPTIONAL: progress bar
# progressr::handlers(global = TRUE)
#predictors
predictors = c(
"koppen_zone", #character
"soil_type", #factor
"topo_elevation", #numeric
"soil_temperature_mean" #numeric
)
#predictors ordered from lower to higher multicollinearity
x <- cor_select(
df = vi_smol,
predictors = predictors,
max_cor = 0.7
)
x
#with custom preference order
x <- cor_select(
df = vi_smol,
predictors = predictors,
preference_order = c(
"koppen_zone",
"soil_type"
),
max_cor = 0.7
)
x
#with automated preference order
df_preference <- preference_order(
df = vi_smol,
response = "vi_numeric",
predictors = predictors
)
df_preference
x <- cor_select(
df = vi_smol,
predictors = predictors,
preference_order = df_preference,
max_cor = 0.7
)
x
#OPTIONAL: disable parallelization
#future::plan(future::sequential)
Run the code above in your browser using DataLab