OneBite.Dev - Coding blog in a bite size

convert a string to uppercase in R

Code snippet on how to convert a string to uppercase in R

toupper <- function(x) {
  return (toupper(x))
}

This code utilizes a pre-built function in the R language called “toupper”. It creates a custom function called “toupper”, which takes in a single argument, represented by ‘x’. The function then uses the built-in “toupper” function to convert the argument to uppercase and returns the result. This can be used to quickly convert a string to uppercase by simply calling the custom function. For example, if we wanted to convert the string “Hello world” to uppercase, we would call the function with “toupper(“Hello world”)” which would return the uppercase string “HELLO WORLD”.

r