remove_redundant_vars | R Documentation |
Remove redundant variables from a data.frame based on a threshold value. This is done by calculating all the intercorrelations, then finding those that correlate at or above the threshold (absolute value), then removing the second pair of each variable and not removing more variables than strictly necessary.
remove_redundant_vars(
df,
threshold = 0.9,
cor_method = "pearson",
messages = T
)
df |
(data.frame) A data.frame with numeric variables. |
threshold |
(numeric scalar) A threshold above which intercorrelations are removed. Defaults to .9. |
cor_method |
(character scalar) The correlation method to use. Parameter is fed to cor(). Defaults to "pearson". |
messages |
(boolean) Whether to print diagnostic messages. |
remove_redundant_vars(iris[-5]) %>% head
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.