check_bounded_integer_scalar: Check integer scalar within bounds

View source: R/check.R

check_bounded_integer_scalarR Documentation

Check integer scalar within bounds

Description

Check integer scalar within bounds

Usage

check_bounded_integer_scalar(
  x,
  lower = -Inf,
  upper = Inf,
  arg_name = deparse(substitute(x))
)

Arguments

x

Numeric: Value to check. Must be a single non-NA whole number.

lower

Numeric scalar: Lower bound, inclusive.

upper

Numeric scalar: Upper bound, inclusive.

arg_name

Character: Argument name to use in error messages.

Details

For bounds not covered by the fixed-range checks: check_pos_integer_scalar() is ⁠[1, Inf)⁠, and there is no non-negative or upper-bounded equivalent. Integer-typed inputs (5L) and double-typed whole numbers (5) are both accepted, matching check_integer_scalar. Both bounds are inclusive; an exclusive integer bound is the next whole number in.

Value

Called for side effects. Throws an error if checks fail.

Author(s)

EDG

Examples

check_bounded_integer_scalar(5L, lower = 0, upper = 20)
check_bounded_integer_scalar(0, lower = 0)
# Throw error:
try(check_bounded_integer_scalar(25, lower = 0, upper = 20))
try(check_bounded_integer_scalar(1.5, lower = 0))

rtemis.core documentation built on Sept. 20, 2026, 9:06 a.m.