Learn R Programming

fb4package (version 2.0.0)

check_numeric_value: Check Numeric Value

Description

Fast validation of numeric values with basic range checking. Simplified utility function for common validation needs.

Usage

check_numeric_value(value, name, min_val = -Inf, max_val = Inf)

Value

The original value (numeric, same length as input), returned unchanged when all checks pass. Throws an error if value

is NULL, non-numeric, contains non-finite elements (NA,

NaN, Inf), or falls outside [min_val, max_val].

Arguments

value

Value to validate

name

Parameter name for error messages

min_val

Minimum allowed value (default -Inf)

max_val

Maximum allowed value (default Inf)

Details

Performs essential validations:

  • Not NULL

  • Numeric type

  • Finite values (no NA, NaN, Inf)

  • Within specified range

Examples

Run this code
check_numeric_value(5, "weight")
try(check_numeric_value(-1, "weight", min_val = 0))
try(check_numeric_value(NA, "weight"))

Run the code above in your browser using DataLab