Skip to contents

check_interval() ensures that the interval is valid (i.e., lower < upper) and that h satisfies h <= |upper - lower|. check_is_interval() returns a logical value indicating whether the interval is valid.

Usage

check_interval(h, lower, upper)

check_is_interval(h, lower, upper)

Arguments

h

A numeric value to compare with the interval width.

lower

The lower bound of the interval.

upper

The upper bound of the interval.

Value

  • check_interval(): A list containing lower, upper, and h if valid; otherwise, raises an error.

  • check_is_interval(): Logical value, TRUE if the parameters form a valid interval, and FALSE otherwise.

Examples

# Examples for check_interval()
# -----------------------------
check_interval(h = 2, lower = 1, upper = 5)
#> $lower
#> [1] 1
#> 
#> $upper
#> [1] 5
#> 
#> $h
#> [1] 2
#> 
try(check_interval(h = 10, lower = 1, upper = 5))
#> Error in check_interval(h = 10, lower = 1, upper = 5) : 
#>   Expected 'h' to be less than or equal to |upper - lower| = 4 but got: h = 10

# Examples for check_is_interval()
# --------------------------------
check_is_interval(h = 2, lower = 1, upper = 5)
#> [1] TRUE
check_is_interval(h = 10, lower = 1, upper = 5)
#> [1] FALSE