View source: R/check_choice_character.R
check_choice_character | R Documentation |
Check if an object is an element of a given set in
the object name. The function is based on checkmate::check_choice
,
but includes the argument ignore.case
.
check_choice_character(
x,
choices,
null.ok = FALSE,
ignore.case = FALSE,
fmatch = FALSE
)
assert_choice_character(
x,
choices,
null.ok = FALSE,
ignore.case = FALSE,
fmatch = FALSE,
.var.name = checkmate::vname(x),
comment = NULL,
add = NULL
)
x |
[ |
choices |
[ |
null.ok |
[ |
ignore.case |
[ |
fmatch |
[ |
.var.name |
[ |
comment |
[ |
add |
[ |
The object must be of type character. The check is intended
for functions were using camelCase may make the argument easier
to remember. Therefore, the function will ignore case if
ignore.case = TRUE
.
Depending on the function prefix:
If the check is successful, the function
assert_choice_character
return x
invisibly, whereas
check_choice_character
return TRUE
.
If the check is not successful,
assert_choice_character
throws an error message and
check_choice_character
returns a string with the error message.
Petter Hopp Petter.Hopp@vetinst.no
# returns TRUE
check_choice_character(x = "APPLE",
choices = c("Apple", "Pear", "Orange"),
null.ok = FALSE,
ignore.case = TRUE,
fmatch = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.