How to convert a string to uppercase in R

The toupper() function in R converts a string to uppercase.

The following figure shows a visual representation of the toupper() function.

Visual representation of the toupper() function

Syntax

toupper(string)

Parameter

As a parameter, the toupper() function requires a string that is to be converted to uppercase.

Return value

The toupper() function returns a string that is converted to uppercase.

Code

The code below shows how the toupper() function works.

#String
a <- toupper("educative");
print(paste0("toupper('educative'): ", a))
#String with number
b <- toupper("educative09");
print(paste0("toupper('educative09'): ", b))

Free Resources