sparseThreshold: sparseThreshold

Description Usage Arguments Value Author(s) Examples

Description

Pushes the smaller values (in absolute value) to zero to achieve a certain nonzero ratio. In other words, the nonzero values closest to zero are assigned zero to achieve at least the specified nonzero ratio.

Usage

1
  sparseThreshold(z, nzr=.1)

Arguments

z

a sparse vector or matrix

nzr

the desired nonzero ratio

Value

Returns the variable z, with more or equal nonzero elements to achieve at least a nonzero ratio of nzr

Author(s)

Michael Love

Examples

1
2
3
4
sds <- simulateSparseDataSet(100, c(5,5), nzs=.5, nzg=.3)
nnzero(sparseData(sds))/prod(dim(sds))
sparseData(sds) <- sparseThreshold(sparseData(sds), .1)
nnzero(sparseData(sds))/prod(dim(sds))

mikelove/SparseData documentation built on May 22, 2019, 10:52 p.m.