Convert Letters to Upper and Lower Case

A family of the str_to_*() functions convert letters to upper and lower case.

library(stringr)x <- "I sAw a pIeCe oF SizZlinG bAcOn."

Convert all letters to upper case.

str_to_upper(x)

Output:

[1] "I SAW A PIECE OF SIZZLING BACON."

Convert all letters to lower case.

str_to_lower(x)

Output:

[1] "i saw a piece of sizzling bacon."

Convert to title case, where only the first letter of each word is capitalized.

str_to_title(x)

Output:

[1] "I Saw A Piece Of Sizzling Bacon."

Convert to sentence case, where only the first letter is capitalized.

str_to_sentence(x)

Output:

[1] "I saw a piece of sizzling bacon."