Description Usage Arguments Details Value Examples
View source: R/remove-constant.R
remove_constant()
removes zero-variance columns from sparse and dense
matrices.
1 2 3 4 5 6 7 | remove_constant(x)
## S3 method for class 'CsparseMatrix'
remove_constant(x)
## S3 method for class 'matrix'
remove_constant(x)
|
x |
A |
remove_constant()
is an S3 generic with methods for:
CsparseMatrix
matrix
x
with zero-variance 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)
colnames(x) <- paste0("x", 1:3)
x <- cbind(x, "x4" = 1, "x5" = 54)
# Print x
x
# Same matrix in dense format
xdense <- as.matrix(x)
# Drop constant columns
remove_constant(x)
remove_constant(xdense)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.