| check_enum | R Documentation |
Checks if a value is in a set of allowed values, and throws an error if not.
check_enum(x, allowed_values, arg_name = deparse(substitute(x)))
x |
Value to check. |
allowed_values |
Vector of allowed values. |
arg_name |
Character: Name of the variable for error messages. |
Called for side effects. Throws an error if x is not in allowed_values, returns x invisibly otherwise.
EDG
check_enum("apple", c("apple", "banana", "cherry"))
# Throws error:
try(check_enum("granola", c("croissant", "bagel", "scramble")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.