Check if an argument is a vector of probability numbers (i.e., values between 0 and 1).
Usage
check_prob(x, alt_null = FALSE)
Arguments
- x
Function argument that is being checked.
- alt_null
Logical. If TRUE, NULL is treated as valid input.
Value
If the argument is a vector of probability numbers, it returns invisible
NULL. Otherwise, the function throws an error.
Examples
if (FALSE) { # \dontrun{
check_prob(c(0.1, 0.5, 0.9))
check_prob(c(0, 1, 0.5))
check_prob(c(-0.1, 0.5, 1.1))
check_prob("text")
check_prob(NULL, alt_null = TRUE)
} # }