Clip vector to bounds
clip.vector.RdClips a numeric vector to specified upper and lower bounds. Use for constraining values in weighting, imputation, or error checking.
Details
Applies pmin and pmax to enforce bounds.
Optionally removes NA values.
Returns clipped vector; does not modify input by reference.
See also
fillna
Other utility functions:
archive_file(),
fillna(),
weighted.median(),
weighted.percentile()
Examples
clip.vector(c(-1, 0, 5), ub = 3, lb = 0)
#> [1] 0 0 3