Check that x is a character vector of the correct length with only allowed
character values.
Usage
all_characters(x, allow_empty = FALSE, allow_zero = FALSE, allow_NA = FALSE)
is_character(x, allow_empty = FALSE, allow_zero = FALSE, allow_NA = FALSE)Value
TRUE or FALSE indicating if x is a character vector of the
correct length with only allowed character values.
See also
The vignettes about design choices and about type coercion.
Other collections of checks on type and length:
all_names(),
is_logical(),
is_natural(),
is_number(),
is_zerolength()
Examples
is_character("a") # TRUE
#> [1] TRUE
is_character(c("a", "b")) # FALSE: incorrect length
#> [1] FALSE
all_characters(c("a", "b")) # TRUE
#> [1] TRUE
is_character(1) # FALSE: incorrect type
#> [1] FALSE
is_character(NA_character_) # FALSE: default 'allow_NA' is FALSE
#> [1] FALSE
is_character(NA_character_, allow_NA = TRUE) # TRUE
#> [1] TRUE
is_character(NA, allow_NA = TRUE) # FALSE: incorrect type
#> [1] FALSE