check_floatpos: Check positive float

View source: R/check.R

check_floatposR Documentation

Check positive float

Description

Check positive float

Usage

check_floatpos(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.

Details

Checking with is.numeric() allows integer inputs as well, which should be ok since it is unlikely the function that consumes this will enforce double type only, but instead is most likely to allow implicit coercion from integer to numeric.

Value

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

Author(s)

EDG

Examples

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

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