Check if two limits are valid, where the lower limit is less than the upper limit
Source:R/check_limits.R
check-limits.Rd
check_limits()
and check_is_limits()
functions validate if
the provided lower
and upper
limits are numeric and satisfy
the condition that lower
is less than upper
.
check_limits()
raises an error if the condition is not met, while
check_is_limits()
returns TRUE
if the limits are valid, and
FALSE
otherwise.
Usage
check_limits(lower, upper, lower_par_name = "lower", upper_par_name = "upper")
check_is_limits(lower, upper)
Value
check_limits()
: Returns a list containinglower
andupper
limits if valid, or raises an error iflower
is not less thanupper
.check_is_limits()
: Logical value,TRUE
if the limits are valid,FALSE
otherwise.
Examples
# Examples for check_limits()
# ---------------------------
check_limits(1, 5)
#> $lower
#> [1] 1
#>
#> $upper
#> [1] 5
#>
try(check_limits(5, 3))
#> Error in check_limits(5, 3) :
#> Expected 'lower' to be less than 'upper' but got 5 and 3 respectively.
check_limits(-10, -5)
#> $lower
#> [1] -10
#>
#> $upper
#> [1] -5
#>
check_limits(0, 10)
#> $lower
#> [1] 0
#>
#> $upper
#> [1] 10
#>
try(check_limits(3, 3))
#> Error in check_limits(3, 3) :
#> Expected 'lower' to be less than 'upper' but got 3 and 3 respectively.
# Examples for check_is_limits()
# ------------------------------
check_is_limits(1, 5)
#> [1] TRUE
check_is_limits(5, 3)
#> [1] FALSE
check_is_limits(-10, -5)
#> [1] TRUE
check_is_limits(0, 10)
#> [1] TRUE
check_is_limits(3, 3)
#> [1] FALSE