Learn R Programming

assertive (version 0.2-1)

assert_is_a_non_empty_string: Is the input of type character?

Description

Checks to see if the input is of type character.

Usage

assert_is_a_non_empty_string(x)

assert_is_a_string(x)

assert_is_an_empty_string(x)

assert_all_are_numeric_strings(x)

assert_any_are_numeric_strings(x)

assert_all_strings_are_missing_or_empty(x)

assert_any_strings_are_missing_or_empty(x)

assert_all_strings_are_not_missing_nor_empty(x)

assert_any_strings_are_not_missing_nor_empty(x)

assert_all_are_not_missing_nor_empty_characters(x)

assert_any_are_not_missing_nor_empty_characters(x)

assert_is_character(x)

is_a_non_empty_string(x, .xname = get_name_in_parent(x))

is_a_string(x, .xname = get_name_in_parent(x))

is_an_empty_string(x, .xname = get_name_in_parent(x))

is_empty_character(x)

is_missing_or_empty_character(x)

is_not_missing_nor_empty_character(x)

is_numeric_string(x)

is_character(x, .xname = get_name_in_parent(x))

Arguments

x
Input to check.
.xname
Not intended to be used directly.

Value

  • is_character wraps is.character, providing more information on failure. is_a_string returns TRUE if the input is character and scalar. is_an_empty_string returns TRUE if the input is "". is_numeric_string is vectorised, returning TRUE when the inputs are not NA after conversion to character and then numeric. is_missing_or_empty_string is also vectorised, returning TRUE when the input is "" or NA. The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

See Also

is.character and is_scalar.

Examples

Run this code
x <- c("a", "", NA)
is_empty_character(x)
is_missing_or_empty_character(x)
is_not_missing_nor_empty_character(x)
is_an_empty_string(x)
is_numeric_string(c("1", "1.1", "-1.1e1", "one", NA))
assert_is_character(letters)
assert_is_a_string("foo bar baz")
assert_all_strings_are_missing_or_empty(c("", NA))
assert_any_strings_are_missing_or_empty(c("a", NA, "b"))
assert_all_are_numeric_strings(c("1", "2.3", "-4.5", "6e7", "8E-9"))
assert_any_are_numeric_strings(c("1", "Not a number"))

Run the code above in your browser using DataLab