OneBite.Dev - Coding blog in a bite size

capitalize a string in R

Code snippet on how to capitalize a string in R

my_string <- "this is an example"

# Use the toUpper() function to capitalize the characters of the string
my_string <- toUpper(my_string)

# Print the updated string
print(my_string)

This code is used to capitalize a string in R. First, a string is saved in the variable ‘my_string’. Then the toUpper() function is used to capitalize the characters of the string. The capitalized string is then printed using the print() function. The output of this code will be “THIS IS AN EXAMPLE”.

r