confined {DMTL} | R Documentation |
Restrict data in a given interval
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
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 |
Value
The filtered vector.
Examples
x <- rnorm(100, 0, 1)
x_filt <- confined(x, lims = c(-0.5, 0.5))
print(range(x_filt))
[Package DMTL version 0.1.2 Index]