Description Usage Arguments Details Value Examples
View source: R/remove-correlated.R
remove_correlated
removes one of column-pairs from sparse and dense
matrices that have sample correlation value greater than a user-defined
threshold.
1 2 3 4 5 6 7 | remove_correlated(x, threshold)
## S3 method for class 'CsparseMatrix'
remove_correlated(x, threshold = 0.99)
## S3 method for class 'matrix'
remove_correlated(x, threshold = 0.99)
|
x |
A |
threshold |
A double between 0 and 1 specifying the absolute correlation threshold value at which to remove columns. |
remove_correlated()
is an S3 generic with methods for:
CsparseMatrix
matrix
x
with one of highly correlated column-pairs removed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Create a sparse matrix with very sparse columns
x <- Matrix::rsparsematrix(10, 5, 0.5)
x <- cbind(x, x[, 4:5], x[, 4:5])
# Create two perfectly correlated columns
colnames(x) <- paste0("x", 1:9)
# Print x
x
# Same matrix in dense format
xdense <- as.matrix(x)
# Drop highly correlated columns
remove_correlated(x, threshold = 0.99)
remove_correlated(xdense, threshold = 0.99)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.