nchar() / toupper()
Try it yourself →Length and case conversion.
Syntax
nchar(s) toupper(s) tolower(s)
Description
nchar gives the character count (length() is the vector length!). toupper/tolower convert cases.
Example
s <- "HexLibrary" cat(nchar(s), "\n", sep="") cat(toupper(s), "\n", sep="") cat(tolower(s), "\n", sep="")
Expected output
10 HEXLIBRARY hexlibrary
When to use?
Input validation, text normalization.
Common mistakes
- ⚠️ Text length is with nchar(), not length().