Skip to contents

Check if an argument is a nonnegative numeric scalar.

Usage

check_nonnegative_scalar(x, alt_null = FALSE)

Arguments

x

Function argument that is being checked.

alt_null

Logical. If TRUE, NULL is treated as valid input.

Value

If the argument is a nonnegative numeric scalar, it returns invisible NULL. Otherwise, the function throws an error.

Examples

if (FALSE) { # \dontrun{
check_nonnegative_scalar(5)
check_nonnegative_scalar(0)
check_nonnegative_scalar(-3)
check_nonnegative_scalar("text")
check_nonnegative_scalar(c(1, 2))
check_nonnegative_scalar(NULL, alt_null = TRUE)
} # }