This function validates whether a numeric value is a valid count (integer of zero or greater).
Arguments
- x
Numeric value to validate as a count.
- include_zero
Logical, whether to include zero as a valid count.
Examples
validate_count(0) # TRUE
#> [1] TRUE
validate_count(3) # TRUE
#> [1] TRUE
try(validate_count(0, include_zero = FALSE)) # Error: Not a valid count
#> Error in validate_count(0, include_zero = FALSE) :
#> Not a valid count value (i.e., integer of zero or greater).
try(validate_count(-1)) # Error: Not a valid count value.
#> Error in validate_count(-1) :
#> Not a valid count value (i.e., integer of zero or greater).