R Tutorial R Charts & Graphs R Statistics R References

R - toupper() Function



The R toupper() function is used to convert all characters of the string in uppercase. Any symbol, space, or number in the string is ignored while applying this function. Only alphabet are converted. The syntax for using this function is given below:

Syntax

toupper(x)

Parameters

x Required. Specify text to be converted.

Return Value

Returns the string with all characters of the specified string in uppercase.

Example:

The example below shows the usage of toupper() function.

x1 <- "Hello World! 123"
x2 <- toupper(x1)
cat("x1:", x1, "\n")
cat("x2:", x2, "\n")

cat("\n")

v1 <- c("Python", "C++", "Java", "SQL", "R")
v2 <- toupper(v1)
cat("v1:", v1, "\n")
cat("v2:", v2, "\n")

The output of the above code will be:

x1: Hello World! 123 
x2: HELLO WORLD! 123 

v1: Python C++ Java SQL R 
v2: PYTHON C++ JAVA SQL R 

❮ R String Functions

5