Zapsmall: Zapsmall Data Frame Columns and Numeric Vectors

View source: R/Zapsmall.R

ZapsmallR Documentation

Zapsmall Data Frame Columns and Numeric Vectors

Description

Put to zero values "close" to zero.

Usage

## Default S3 method:
Zapsmall(x, digits = getOption("digits"), ...)
## S3 method for class 'data.frame'
Zapsmall(x, digits = getOption("digits"), except = NULL, ...)

Arguments

x

A data.frame with numeric columns or a numeric vector.

digits

Integer indicating the precision to be used.

except

Indices of columns not to be zapped (if any).

...

Arguments for future expansion.

Details

This function "extends" to data.frame objects function zapsmall from the package base.
The method for class data.frame 'zaps' values close to zero occurring in columns of x. Argument except can be used to prevent specific columns from being zapped.
The default method is a bare copy of the original function from package base.

Value

An object of the same class of x, with values "close" to zero zapped to zero.

Author(s)

Diego Zardetto

See Also

The original function zapsmall from package base.

Examples

# Create a test data frame with columns containing
# values of different orders of magnitude:
data <- data.frame(a = pi*10^(-8:1), b = c(rep(1000,8), c(1E-5, 1E-6)))

# Print on screen the test data frame:
data

# Compare with its zapped version:
Zapsmall(data)

DiegoZardetto/ReGenesees documentation built on Dec. 16, 2024, 2:03 p.m.