Skip to contents

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)

Arguments

lower

The lower limit to check.

upper

The upper limit to check.

lower_par_name

A name for the parameter lower to display in error messages.

upper_par_name

A name for the parameter upper to display in error messages.

Value

  • check_limits(): Returns a list containing lower and upper limits if valid, or raises an error if lower is not less than upper.

  • 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