check_float0pos: Check float greater than or equal to 0

View source: R/check.R

check_float0posR Documentation

Check float greater than or equal to 0

Description

Checks if an input is a numeric vector containing non-negative (>= 0) values and no NAs. It is designed to validate function arguments.

Usage

check_float0pos(x, allow_null = TRUE, arg_name = deparse(substitute(x)))

Arguments

x

Numeric vector.

allow_null

Logical: If TRUE, NULL values are allowed and return early.

arg_name

Character: Name of the variable for error messages.

Value

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

Author(s)

EDG

Examples

check_float0pos(c(0, 0.5, 1))
# Allows integers since they are numeric and can be coerced to double without loss of information
check_float0pos(c(0L, 1L))
# Throws error:
try(check_float0pos(c(-1.5, 0, 1.5)))

rtemis.core documentation built on April 22, 2026, 1:11 a.m.