Convert First letter of every word to Uppercase in R Programming – str_to_title() Function

str_to_title() Function in R Language is used to convert the first letter of every word of a string to Uppercase and the rest of the letters are converted to lower case.

Note: This function uses 'stringr' library.

Syntax: str_to_title(string)

Parameter:
string: string to be converted

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R Program to illustrate 
# the use of str_to_title function
  
# Loading Library
library(stringr)
  
# Creating a string
str <- "geeks for geeks"
  
# Calling str_to_title() function
str_to_title(str

chevron_right


Output:

[1] "Geeks For Geeks"

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R Program to illustrate 
# the use of str_to_title function
  
# Loading Library
library(stringr)
  
# Creating a string
str <- "GEEKS FOR GEEKS"
  
# Calling str_to_title() function
str_to_title(str

chevron_right


Output:

[1] "Geeks For Geeks"
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.