Filters vector x
to only keep elements which are in bounds [lower, upper]
.
This is equivalent to the following, but tries to avoid unnecessary allocations:
Currently only works for integer x
.
Arguments
- x
(
integer()
)
Vector to filter.- lower
(
integer(1)
)
Lower bound.- upper
(
integer(1)
)
Upper bound.
Examples
keep_in_bounds(sample(20), 5, 10)
#> [1] 10 7 6 9 8 5