is_bounded {dynutils} | R Documentation |
Check whether a value within a certain interval
Description
Check whether a value within a certain interval
Usage
is_bounded(
x,
lower_bound = -Inf,
lower_closed = FALSE,
upper_bound = Inf,
upper_closed = FALSE
)
Arguments
x |
A value to be tested |
lower_bound |
The lower bound |
lower_closed |
Whether the lower bound is closed |
upper_bound |
The upper bound |
upper_closed |
Whether the upper bound is closed |
Examples
## Not run:
library(assertthat)
assert_that(is_bounded(10))
# TRUE
assert_that(is_bounded(10:30))
# TRUE
assert_that(is_bounded(Inf))
# Error: Inf is not bounded by (-Inf,Inf)
assert_that(is_bounded(10, lower_bound = 20))
# Error: 10 is not bounded by (20,Inf)
assert_that(is_bounded(
10,
lower_bound = 20,
lower_closed = TRUE,
upper_bound = 30,
upper_closed = FALSE
))
# Error: 10 is not bounded by [20,30)
## End(Not run)
[Package dynutils version 1.0.11 Index]