Description Usage Arguments Details Value Examples
remove_empty()
removes all-zero columns from sparse and dense matrices.
1 2 3 4 5 6 7 | remove_empty(x)
## S3 method for class 'CsparseMatrix'
remove_empty(x)
## S3 method for class 'matrix'
remove_empty(x)
|
x |
A |
remove_empty()
is an S3 generic with methods for:
CsparseMatrix
matrix
x
with all-zero columns removed.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Create a sparse matrix with constant columns
x <- Matrix::rsparsematrix(10, 3, 0.1)
x <- cbind(x, 0)
colnames(x) <- paste0("x", 1:4)
# Print x
x
# Same matrix in dense format
xdense <- as.matrix(x)
# Drop empty columns
remove_empty(x)
remove_empty(xdense)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.