confined: Restrict data in a given interval

Description Usage Arguments Value Examples

View source: R/lambda_functions.R

Description

This function filters a data vector using a given interval so that only the values falling inside the interval remains and any value that is less than the leftmost end gets replaced by that end-value, and similarly, any value greater than the rightmost end gets replaced by that end-value.

Usage

1
confined(x, lims = c(0, 1))

Arguments

x

Vector containing data.

lims

Limit for the values. Values falling within this limit will pass without any change. Any value x < lims[1] will get replaced by lims[1], and any value x > lims[2] will get replaced by lims[2]. Defaults to c(0, 1).

Value

The filtered vector.

Examples

1
2
3
x <- rnorm(100, 0, 1)
x_filt <- confined(x, lims = c(-0.5, 0.5))
print(range(x_filt))

DMTL documentation built on Feb. 18, 2021, 5:06 p.m.