Restore custom capitalisation in a string
Arguments
- x
A string (or vector of strings) in which capitalisation needs to be restored
- items_to_capitalise
Whole words or acronyms in which capitalisation must be retained; special characters can be included (e.g. "R2-D2"). Matching ignores case, so items are restored whether their capitalisation has been lost completely (e.g. "ebook") or partially (e.g. "Ebook").
See also
Other verbaliseR functions:
listify(),
num_to_text(),
pluralise(),
prettify_date()
Examples
x <- "Should i tell c-3po the french call him z-6po?"
restore_capitals(x, c("I", "C-3PO", "French", "Z-6PO"))
#> [1] "Should I tell C-3PO the French call him Z-6PO?"
