Learn R Programming

testextra (version 0.1.0.1)

string-tests: Tests for strings

Description

Tests for strings

Usage

is_nonempty_string(x)

is_optional_string(x)

Arguments

x

a character vector/string.

Functions

  • is_nonempty_string: Test that a character is both a string (character vector of length one) and that it is non-empty, has at least one character and is not missing.

  • is_optional_string: Check for an optional string: must be a character, not missing, a vector of either length 0 or 1, and if provided must not be empty ("").

Examples

Run this code
# NOT RUN {
# TRUE
is_nonempty_string("hello")

# All FALSE
x <- c("hello", "world")
is_nonempty_string(x)
is_nonempty_string(NA_character_)
is_nonempty_string(character(0))
is_nonempty_string(NULL)
is_nonempty_string(12345)
# }

Run the code above in your browser using DataLab