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