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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# nzchar function
  
# Initializing a character vector
x <- c("GFG", "gfg")
y <- c("a", "b", "c")
  
# Calling the nzchar() function
nzchar(x)
nzchar(y)

chevron_right


Output :

[1] TRUE TRUE
[1] TRUE TRUE TRUE

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# nzchar function
  
# Initializing a character vector
x <- c("")
y <- c("", "")
  
# Calling the nzchar() function
nzchar(x)
nzchar(y)

chevron_right


Output:

[1] FALSE
[1] FALSE FALSE
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.