clamp values in the range of lims

clamp(x, lims = c(0, 1), fill.na = FALSE)

clamp_min(x, value = 0)

clamp_max(x, value = 0)

Arguments

x

Numeric vector

lims

limits

fill.na

If true, values of lims are set to NA; else, values are just constrained in the range of lims.

Examples

clamp(1:10, lims = c(4, 7), fill.na = TRUE) 
#>  [1] NA NA NA  4  5  6  7 NA NA NA