View source: R/arg_character.R
| arg_character | R Documentation |
Checks whether an argument is a character vector (arg_character()), a character scalar (arg_string()), or a factor (arg_factor()).
arg_character(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
arg_string(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
arg_factor(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
x |
the argument to be checked |
.arg |
the name of the argument supplied to |
.msg |
an optional alternative message to display if an error is thrown instead of the default message. |
.call |
the execution environment of a currently running function, e.g. |
NA values in arg_string() will cause an error to be thrown.
Returns NULL invisibly if an error is not thrown.
is.character(), is.factor(), rlang::is_string()
f <- function(z) {
arg_string(z)
}
try(f("a")) # No error
try(f(c("a", "b"))) # Error: arg_string() requires scalar
try(f(NA)) # NAs not allowed for arg_string()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.