R program to convert string from lowercase to uppercase?

toupper() method in R programming is used to convert the lowercase string to uppercase string.

In R, there are several ways to convert a string from lowercase to uppercase. Here are a few examples:

    1. Using the toupper() function: The toupper() function converts all lowercase characters in a string to uppercase. Here's an example: 

 

string <- "hello world"
string_upper <- toupper(string)
print(string_upper)

Output: "HELLO WORLD"

    1. Using the str_to_upper() function from the stringr package: The stringr package provides a convenient function str_to_upper() that can be used to convert a string from lowercase to uppercase. Here's an example: 

 

library(stringr)
string <- "hello world"
string_upper <- str_to_upper(string)
print(string_upper)

Output: "HELLO WORLD"

    1. Using the base R function toUpper(): The toUpper() function is another base R function that can be used to convert a string from lowercase to uppercase. Here's an example: 

 

string <- "hello world"
string_upper <- toUpper(string)
print(string_upper)

Output: "HELLO WORLD"

All of these methods will result in the same output, which is the original string converted to uppercase.

Submit Your Programming Assignment Details