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)
print(x1)
print(x2)

cat("\n")

v1 <- c("Python", "C++", "Java", "SQL", "R")
v2 <- toupper(v1)
print(v1)
print(v2)

The output of the above code will be:

[1] "Hello World! 123"
[1] "HELLO WORLD! 123"

[1] "Python" "C++"    "Java"   "SQL"    "R"     
[1] "PYTHON" "C++"    "JAVA"   "SQL"    "R" 

❮ R String Functions