cor_matrix | R Documentation |
If argument 'df' results from cor_df()
, transforms it to a correlation matrix. If argument 'df' is a dataframe with predictors, and the argument 'predictors' is provided then cor_df()
is used to compute pairwise correlations, and the result is transformed to matrix.
Accepts a parallelization setup via future::plan()
and a progress bar via progressr::handlers()
(see examples).
cor_matrix(df = NULL, predictors = NULL)
df |
(required; data frame, tibble, or sf) A data frame with responses and predictors. Default: NULL. |
predictors |
(optional; character vector) Names of the predictors to select from |
correlation matrix
Blas M. Benito, PhD
Other pairwise_correlation:
cor_clusters()
,
cor_cramer_v()
,
cor_df()
,
cor_select()
data(
vi,
vi_predictors
)
#reduce size of vi to speed-up example execution
vi <- vi[1:1000, ]
#mixed predictors
vi_predictors <- vi_predictors[1:10]
#parallelization setup
future::plan(
future::multisession,
workers = 2 #set to parallelly::availableCores() - 1
)
#progress bar
# progressr::handlers(global = TRUE)
#correlation data frame
df <- cor_df(
df = vi,
predictors = vi_predictors
)
df
#correlation matrix
m <- cor_matrix(
df = df
)
m
#generating it from the original data
m <- cor_matrix(
df = vi,
predictors = vi_predictors
)
m
#disable parallelization
future::plan(future::sequential)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.