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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201474, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/nchar(68): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78