Takes a character vector, or list object of character vectors and converts the case to capital case (AKA, title case). Outputs the same object and number of elements as the input unless the collapseall flag is set to TRUE, in which case it will output a single character vector.

tocapital(x, fix_mc = FALSE, collapseall = FALSE)

Arguments

x

A character vector, or list object of character vectors.

fix_mc

A logical/boolean flag to indicate if Mc* names (like McDowell) should be double capitalized. Default is FALSE.

collapseall

A logical/boolean flag to indicate whether or not you want a single character vector as your output. Default is FALSE.

See also

toupper, tolower, tocamel

Examples

tocapital("jonny appleseed")
#> [1] "Jonny Appleseed"
# using a list object tocapital( list( c("THE", "DARK", "KNIGHT") , c("rises", "from the", "lazerus PIT") ) )
#> [,1] [,2] #> [1,] "The" "Rises" #> [2,] "Dark" "From The" #> [3,] "Knight" "Lazerus Pit"
# using a list object and collapseall tocapital( list( c("THE", "DARK", "KNIGHT") , c("rises", "from the", "lazerus PIT") ) , collapseall = TRUE )
#> [1] "The Dark Knight Rises From The Lazerus Pit"
# examples of not fixing Mc* names (the default) vs fixing them tocapital(c("jonny appleseed", "GraNDpa CrIPEs-mcgee"))
#> [1] "Jonny Appleseed" "Grandpa Cripes-Mcgee"
tocapital( c("jonny appleseed", "GraNDpa CrIPEs-mcgee") , fix_mc = TRUE )
#> [1] "Jonny Appleseed" "Grandpa Cripes-McGee"