| corrSubset | R Documentation |
Extracts one or more variable subsets from a CorrCombo object as data frames.
Typically used after corrSelect or MatSelect to obtain filtered
versions of the original dataset containing only low‐correlation variable combinations.
corrSubset(res, df, which = "best", keepExtra = FALSE)
res |
A |
df |
A data frame or matrix. Must contain all variables listed in |
which |
Subsets to extract. One of:
Subsets are ranked by decreasing size, then increasing average correlation. |
keepExtra |
Logical. If |
A data frame if a single subset is extracted, or a list of data frames if multiple subsets are extracted. Each data frame contains the selected variables (and optionally extras).
A warning is issued if any rows contain missing values in the selected variables.
corrSelect, MatSelect, CorrCombo
# Simulate input data
set.seed(123)
df <- as.data.frame(matrix(rnorm(100), nrow = 10))
colnames(df) <- paste0("V", 1:10)
# Compute correlation matrix
cmat <- cor(df)
# Select subsets using MatSelect (cmat is already a correlation matrix)
res <- MatSelect(cmat, threshold = 0.5)
# Extract the best subset (default)
corrSubset(res, df)
# Extract the second-best subset
corrSubset(res, df, which = 2)
# Extract the first three subsets
corrSubset(res, df, which = 1:3)
# Extract all subsets
corrSubset(res, df, which = "all")
# Extract best subset and retain additional numeric column
df$CopyV1 <- df$V1
corrSubset(res, df, which = 1, keepExtra = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.