tolower & toupper Functions in R (Example)
This R programming tutorial shows how to convert character strings from upper to lower case and the other way around.
Example 1: tolower Function in R
Consider the following character string in R:
x_up <- "AAA" # Create example character string |
x_up <- "AAA" # Create example character string
We can convert all characters of this string to lower case with the tolower function:
tolower(x_up) # Apply tolower function # "aaa" |
tolower(x_up) # Apply tolower function # "aaa"
Example 2: toupper Function in R
Again, we have to create an exemplifying character string:
x_low <- "aaa" # Create another example string |
x_low <- "aaa" # Create another example string
We can change all letters to upper case as follows:
toupper(x_low) # Apply toupper function # "AAA" |
toupper(x_low) # Apply toupper function # "AAA"