powered by
Fast validation of numeric values with basic range checking. Simplified utility function for common validation needs.
check_numeric_value(value, name, min_val = -Inf, max_val = Inf)
The original value (numeric, same length as input), returned unchanged when all checks pass. Throws an error if value
value
is NULL, non-numeric, contains non-finite elements (NA,
NULL
NA
NaN, Inf), or falls outside [min_val, max_val].
NaN
Inf
[min_val, max_val]
Value to validate
Parameter name for error messages
Minimum allowed value (default -Inf)
Maximum allowed value (default Inf)
Performs essential validations:
Not NULL
Numeric type
Finite values (no NA, NaN, Inf)
Within specified range
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