Capitalize the first letters of words in a string. Can either use sentence case (i.e., only the first word capitalized; all = FALSE) or title case (i.e., all words capitalized; all = TRUE).

rat_cap_words(x, all = FALSE)

Arguments

x

A character string

all

Logical. If TRUE, the first letter of every word is capitalized. If FALSE (the default), only the first word is capitalized.

Value

A character string with the specified capitalization.

Examples

name <- c("zip code", "state", "final count")
vapply(name, rat_cap_words, character(1))
#>      zip code         state   final count 
#>    "Zip code"       "State" "Final count" 
vapply(name, rat_cap_words, character(1), all = TRUE)
#>      zip code         state   final count 
#>    "Zip Code"       "State" "Final Count"