Search notes:

R function: nchar

nchar returns the length of a string or lenghs of a string vector.
Other programming languages might call the respective functionality strlen or len or similar.
In earlier versions of R, nchar(NA) apparently returned 2. This behavior can be turned on again with keepNA=F.
A particular useful application of nchar is to see if a string is empty.
#
# How many characters in string
#
#    S.a. ../examples/basic_string_manipulation.R
#
nchar("forty-two")
# [1] 9

nchar(NA)
# [1] NA

nchar(NA, keepNA=F)
# [1] 2
Github repository about-r, path: /functions/nchar.R

See also

String related R functions
character (mode)
Index to (some) R functions

Index