Bound the values of x to lie within the upper and lower bounds.

minmax(x, lower, upper)

Arguments

x

vector of values to limit

lower, upper

lower and upper limits

Value

vector of the same length as x

Examples

set.seed(0) c <- sample(-100:100, 20) c
#> [1] 41 -33 66 28 61 -58 -87 86 -50 -16 -80 5 81 -27 -94 -28 -22 -64 4 #> [20] 9
minmax(c, -10, 10)
#> [1] 10 -10 10 10 10 -10 -10 10 -10 -10 -10 5 10 -10 -10 -10 -10 -10 4 #> [20] 9