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

We can convert all characters of this string to lower case with the tolower function:

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

We can change all letters to upper case as follows:

toupper(x_low)         # Apply toupper function
# "AAA"

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed