Learn R Programming

tensr (version 1.0.1)

trim: Truncates small numbers to 0.

Description

Given an array, matrix, or vector, trim will truncate all elements smaller than epsilon (in absolute value) to zero.

Usage

trim(X, epsilon = 10^-6)

Arguments

X

An array, a matrix, or a vector.

epsilon

A numeric.

Details

All elements in X that are smaller than epsilon (in absolute value) will be set to zero then returned.

Examples

Run this code
# NOT RUN {
X <- c(0, 1, 10^-7, -1, -10^-7)
X
trim(X)
# }

Run the code above in your browser using DataLab