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)
#group predictors using max_cor as clustering threshold
clusters <- cor_clusters(
df = vi_smol,
predictors = c(
"koppen_zone", #character
"soil_type", #factor
"topo_elevation", #numeric
"soil_temperature_mean" #numeric
),
max_cor = 0.75
)
#clusters dataframe
clusters$df
##plot hclust object
# graphics::plot(clusters$hclust)
##plot max_cor threshold
# graphics::abline(
# h = 1 - 0.75,
# col = "red4",
# lty = 3,
# lwd = 2
# )
## OPTIONAL: disable parallelization
#future::plan(future::sequential)
Run the code above in your browser using DataLab