Learn R Programming

spray (version 1.0-9)

zap: Zap small values in a spray object

Description

Generic version of zapsmall()

Usage

zap(x, digits = getOption("digits"))
# S4 method for spray
zapsmall(x, digits = getOption("digits"))

Arguments

x

spray object

digits

number of digits to retain

Details

Given a spray object, coefficients close to zero are ‘zapped’, i.e., replaced by ‘0’, using base::zapsmall(). Function zap() is an easily-typed alias; zapsmall() is the S4 generic.

Note, zap() actually changes the numeric value, it is not just a print method.

Examples

Run this code
# NOT RUN {
S <- spray(matrix(sample(1:50),ncol=2),10^-(1:25))
zap(S)


S-zap(S)        # print method will probably print zeros...
value(S-zap(S)) # ...but they are nevertheless nonzero
# }

Run the code above in your browser using DataLab