If you want to start every string with a capital letter in R, you should know a reliable function that works in every situation. Same as the PROPER function in Excel. Of course, it is possible to write your R functions, but sometimes it is not worth the effort.
Here is my text that I’m using to cover most of the possible situations.
JOHN doe, jEAN Paul, janis,sturis, Julia meryl-bush
The best results to transform every string with the capital letter in R is with the str_to_title function from the stringr package.
stringr::str_to_title("JOHN doe, jEAN Paul, janis,sturis, Julia meryl-bush") # "John Doe, Jean Paul, Janis,Sturis, Julia Meryl-Bush"
Results are as good as with the PROPER function in Microsoft Excel.
Sometimes the popular answer is toTitleCase from the tools package, but it works not so well in the most difficult situations.
tools::toTitleCase("JOHN doe, jEAN Paul, janis,sturis, Julia meryl-bush") # "JOHN Doe, jEAN Paul, Janis,sturis, Julia Meryl-Bush"
If you are interested to learn more about how to learn Excel as an R user, take a look at this Datacornering post.