Skip to Content

Convert String to Lowercase in R

When working with strings in R, it can be handy to know how to quickly change its case. In this tutorial, we will look at how to convert the case of a string to lowercase in R with the help of some examples.

How do I convert a string to lowercase in R?

📚 Discover Online Data Science Courses & Programs (Enroll for Free)

Introductory ⭐

Intermediate ⭐⭐⭐

Advanced ⭐⭐⭐⭐⭐

🔎 Find Data Science Programs 👨‍💻 111,889 already enrolled

Disclaimer: Data Science Parichay is reader supported. When you purchase a course through a link on this site, we may earn a small commission at no additional cost to you. Earned commissions help support this website and its team of writers.

convert string to lowercase in R

You can use the built-in tolower() function to convert a string to lowercase in R. Pass the string you want to convert as an argument to the tolower() function.

The following is the syntax –

# string s to lowercase

It returns the passed string as a lowercase string.

Upskill your career right now →

You can also apply this function to a vector of strings to convert each string in the vector to lowercase.

Let’s now look at some examples of using the tolower() function.

Convert string to lowercase

Here, we will create a string with characters having mixed cases. That is some characters will be uppercase and some lowercase. We’ll then pass the string to the tolower() function.

# create a string
s <- "pLeAsE dO nOt tYPe lIkE THiS"
# convert string to lowercase


[1] "please do not type like this"

You can see that all the characters in the returned string are in lowercase.

Convert a vector of strings to lowercase

You can also apply the tolower() function to a vector of strings.

Let’s look at an example.

Upskill your career right now →

Here, we will create a vector of some string values and then apply the tolower() function on the vector itself.

# create a vector of strings
vec <- c("HELLO", "Howdy", "hoLA", "namaste")
# convert vector to lowercase


[1] "hello"   "howdy"   "hola"    "namaste"

You can see that each string in the resulting vector is in lowercase.

You might also be interested in –

Subscribe to our newsletter for more informative guides and tutorials.
We do not spam and you can opt out any time.


  • Piyush Raj

    Piyush is a data professional passionate about using data to understand things better and make informed decisions. He has experience working as a Data Scientist in the consulting domain and holds an engineering degree from IIT Roorkee. His hobbies include watching cricket, reading, and working on side projects.