Capitalize Words for Titles
This function capitalizes words for use in titles
capwords(s, strict=FALSE, AP=TRUE, onlyfirst=FALSE, preserveMixed=FALSE, sep=" ")
s |
character string to be processed |
strict |
Logical, remove all additional capitalization. |
AP |
Logical, apply the Associated Press (AP) rules for prepositions and conjunctions that should not be capitalized in titles. |
onlyfirst |
Logical, only capitalize the first word. |
preserveMixed |
Logical, preserve the capitalization mixed-case words containing an upper-case letter after a lower-case letter. |
sep |
Character string, word separator |
This function separates the provided character string into separate words using sep
as the word separator. If firstonly==TRUE
, it then capitalizes the first letter the first word, otherwise (the default), it capitalizes the first letter of every word. If AP==TRUE
, it then un-capitalizes words in the Associated Press's (AP) list of prepositions and conjunctions should not be capitalized in titles. Next, it capitalizes the first word. It then re-joins the words using the specified separator.
If preserveMixed==TRUE
, words with an upper-case letter appearing after a lower-case letter will not be changed (e.g. "iDevice").
A character scalar containing the capitalized words.
Gregory R. Warnes greg@warnes.net based on code from the
chartr
manual page,
and taxize_capwords
in the taxize package.
Fogarty, Mignon. Capitalizing Titles: "Which words should you capitalize? Grammar Girl's Quick and Dirty Tips for Better Writing. 9 Jun. 2011. Quick and Dirty Tips Website." Accessed 22 April 2016 http://www.quickanddirtytips.com/education/grammar/capitalizing-titles
capwords("a function to capitalize words in a title") capwords("a function to capitalize words in a title", AP=FALSE) capwords("testing the iProduct for defects") capwords("testing the iProduct for defects", strict=TRUE) capwords("testing the iProduct for defects", onlyfirst=TRUE) capwords("testing the iProduct for defects", preserveMixed=TRUE) capwords("title_using_underscores_as_separators", sep="_")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.