is_single_character: Is the input a single character?

Description Usage Arguments Value Note See Also Examples

View source: R/is-special-string.R

Description

Checks to see if he unput is a single character.

Usage

1
2
3
4
5
6
7
assert_all_are_single_characters(x, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_are_single_characters(x, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

is_single_character(x, .xname)

Arguments

x

A character vector.

na_ignore

A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

.xname

Not intended to be used directly.

Value

is_single_character returns TRUE when the input is a single character (as determined by nchar; this excludes NA). The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

Note

The behaviour of this function has changed so that NA inputs now return NA rather than FALSE.

See Also

nchar

Examples

1
2
x <- c("", "a", "aa", NA)
is_single_character(x)

assertive.strings documentation built on May 1, 2019, 8:45 p.m.