R – String Lower-case

To convert String to lower-case in R language, call tolower() function and pass the string as argument. tolower() returns a new string with all the characters of the input string converted to lower-case.

Examples

In the following example, we take a string value in str variable, and convert this string to lower-case using tolower() function.

example.R

</>
Copy
str <- 'Hello World ABC'
result <- tolower(str)
print(result)

Output

% Rscript example.R
[1] "hello world abc"

If the characters are already in lower-case, then the input string is returned as is.

example.R

</>
Copy
str <- 'hello world'
result <- tolower(str)
print(result)

Output

% Rscript example.R
[1] "hello world"

Conclusion

In this R Tutorial, we have learned to use tolower() function to convert a given string to lower-case in R programming language.