remove_sparse_zeros: Remove Zeros from a Sparse Matrix or Sparse Vector

View source: R/utils.R

remove_sparse_zerosR 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.


MatrixExtra documentation built on May 29, 2024, 2:53 a.m.