Learn R Programming

sjmisc (version 1.2)

is_empty: Check whether string is empty

Description

This function checks whether a string or character vector (of length 1) is empty or not.

Usage

is_empty(x)

Arguments

x
String or character vector of length 1.

Value

  • Logical, TRUE if x is empty, FALSE otherwise.

Examples

Run this code
x <- "test"
is_empty(x)

x <- ""
is_empty(x)

x <- NA
is_empty(x)

x <- NULL
is_empty(x)

# string is not empty
is_empty("")

# however, this trimmed string is
is_empty(trim(""))

Run the code above in your browser using DataLab