toupper and tolower
In this page:
toupper and tolower
toupper() converts a string to all uppercase, and tolower() converts it to all lowercase. Both work element-wise across a vector of strings. They're commonly used for case-insensitive comparisons by normalizing both sides to the same case first.
Note: For case-insensitive comparisons, normalize both strings with tolower() before comparing them with ==.
Example: toupper and tolower
text <- "Hello World"
cat(toupper(text), "\n")
cat(tolower(text), "\n")
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: