Skip to contents

Check if an argument is a numeric scalar within the [0, 1] interval.

Usage

check_prob_scalar(x, alt_null = FALSE)

Arguments

x

Function argument that is being checked.

alt_null

Logical. Should argument accept NULL value.

Value

If the argument is a numeric scalar within the [0, 1] interval, it returns invisible NULL. Otherwise, the function throws an error.

Examples

if (FALSE) { # \dontrun{
check_prob_scalar(0.5)
check_prob_scalar(0)
check_prob_scalar(1)
check_prob_scalar(-0.1)
check_prob_scalar(1.1)
check_prob_scalar("text")
check_prob_scalar(c(0.5, 0.6))
check_prob_scalar(NULL, alt_null = TRUE)
} # }