Skip to contents

Remove empty strings

Usage

strRemoveEmpty(x, naOk = TRUE, spacesOk = TRUE)

Arguments

x

character. Character vector.

naOk

logical(1). Allow NA values to propagate.

spacesOk

logical(1). Consider spaces to be non-empty.

Value

character. Modified vector, with empty strings removed.

Note

Updated 2023-09-28.

Examples

x <- c("", "a", "b", " ", NA)
y <- strRemoveEmpty(x, naOk = TRUE, spacesOk = TRUE)
print(y)
#> [1] "a" "b" " " NA 
y <- strRemoveEmpty(x, naOk = FALSE, spacesOk = FALSE)
print(y)
#> [1] "a" "b"