This is a milder, more explicit version of match.arg which gives a warning
and returns a good default. match.arg() would throw errors which makes
geom/pattern development a bit trickier.
check_default(
x,
options = NULL,
default = NULL,
type = NULL,
prefix = "",
verbose = FALSE
)argument value
valid options this value could take. If this is not NULL, then x is checked to be a member of this set. Default: NULL.
the default value to use if the argument fails the checks.
If default is not NULL, then use it as the fallback value.
If default is NULL and options is not NULL, then use the first value
in options.
NULL, 'num' or 'char'
prefix of warning message.
default: FALSE
original x value if there are no issues, otherwise the default
if given, otherwise the first element in options.