powered by
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:
x
[lower, upper]
x[!is.na(x) & x >= lower & x <= upper]
Currently only works for integer x.
keep_in_bounds(x, lower, upper)
(integer()) with only values in [lower, upper].
(integer()) Vector to filter.
integer()
(integer(1)) Lower bound.
integer(1)
(integer(1)) Upper bound.
keep_in_bounds(sample(20), 5, 10)
Run the code above in your browser using DataLab