remove_sparse_zeros {MatrixExtra}R Documentation

Remove Zeros from a Sparse Matrix or Sparse Vector

Description

Removes the entries in a sparse matrix or sparse vector which have a value of zero but nevertheless are still among the object's values, in any case there are any. Can also remove missing values if desired.

Usage

remove_sparse_zeros(X, na.rm = FALSE)

Arguments

X

A sparse matrix (COO, CSR, CSC) or sparse vector (any type) from the 'Matrix' package, whose values will be removed (left as non-present in the sparse representation) if they are zeros.

na.rm

Whether to also remove missing values ('NA' / 'NaN') from 'X'.

Value

The same matrix / vector X with its zeros removed from the sparse representation.


[Package MatrixExtra version 0.1.15 Index]