# 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 corrSelect
res <- corrSelect(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)
Run the code above in your browser using DataLab