Check if Elements of a Vector are non-empty Strings in R Programming – nzchar() Function
nzchar() function in R Language is used to test whether elements of a character vector are non-empty strings.
Syntax: nzchar(x)
Parameters:
x: character vector
Example 1:
# R program to illustrate# nzchar function # Initializing a character vectorx <- c("GFG", "gfg")y <- c("a", "b", "c") # Calling the nzchar() functionnzchar(x)nzchar(y) |
Output :
[1] TRUE TRUE [1] TRUE TRUE TRUE
Example 2:
# R program to illustrate# nzchar function # Initializing a character vectorx <- c("")y <- c("", "") # Calling the nzchar() functionnzchar(x)nzchar(y) |
Output:
[1] FALSE [1] FALSE FALSE


