Learn R Programming

lambda.tools (version 1.0.9)

confine: Confine values to the given bounds

Description

Given a sequence this function confines the sequence values to within the specified bounds. This behavior is equivalent to clipping in digital signal processing.

Arguments

x
A numeric vector
min.level
The lower bound
max.level
The upper bound

Value

A sequence with values outside of [min.level, max.level] clipped to those values

Usage

confine(x, min.level, max.level) confine(x, min.level=-1, max.level=1)

Details

The confine function can be thought of a transform that limits the range of a sequence. Any values outside the range [min.level, max.level] are adjusted to be exactly min.level or max.level. Care should be taken when using this function as it is not always a good idea to change the value of outliers. Sometimes it is better to remove these values from a data set instead.

See Also

quantize

Examples

Run this code
confine(seq(-2,2, by=.1))

Run the code above in your browser using DataLab