Uppercase the first letter in each word
Arguments
- x
character vector.
- lowercaseAll
logical indicating whether to force all letters to lowercase before applying uppercase to the first letter.
- firstWordOnly
logical indicating whether to apply the uppercase only to the first word in each string. Note that it still applies the logic to every entry in the input vector
x
.- ...
additional arguments are ignored.
Details
This function is a simple mimic of the Perl function ucfirst
which
converts the first letter in each word to uppercase. When
lowercaseAll=TRUE
it also forces all other letters to lowercase,
otherwise mixedCase words will retain capital letters in the middle
of words.
See also
Other jam string functions:
asSize()
,
breaksByVector()
,
fillBlanks()
,
formatInt()
,
gsubOrdered()
,
gsubs()
,
makeNames()
,
nameVector()
,
nameVectorN()
,
padInteger()
,
padString()
,
pasteByRow()
,
pasteByRowOrdered()
,
sizeAsNum()
,
tcount()
Examples
ucfirst("TESTING_ALL_UPPERCASE_INPUT")
#> [1] "TESTING_ALL_UPPERCASE_INPUT"
ucfirst("TESTING_ALL_UPPERCASE_INPUT", TRUE)
#> [1] "Testing_All_Uppercase_Input"
ucfirst("TESTING_ALL_UPPERCASE_INPUT", TRUE, TRUE)
#> [1] "Testing_all_uppercase_input"
ucfirst("testing mixedCase upperAndLower case input")
#> [1] "Testing MixedCase UpperAndLower Case Input"
ucfirst("testing mixedCase upperAndLower case input", TRUE)
#> [1] "Testing Mixedcase Upperandlower Case Input"
ucfirst("testing mixedCase upperAndLower case input", TRUE, TRUE)
#> [1] "Testing mixedcase upperandlower case input"