Upper/Lower/Title Case

Usage

TC(text.var, lower = NULL, ...)
L(text.var, ...)
U(text.var, ...)

Arguments

text.var
The text variable.
lower
A vector of words to retain lower case for (unless first or last word).
...
Other arguments passed to: stri_trans_tolower, stri_trans_toupper, and stri_trans_totitle.

Value

Returns a character vector with new case (lower, upper, or title).

Description

TC - Capitalize titles according to traditional capitalization rules.

L - All lower case.

U - All upper case.

Details

Case wrapper functions for stringi's stri_trans_tolower, stri_trans_toupper, and stri_trans_totitle. Functions are useful within magrittr style chaining.

Note

TC utilizes additional rules for capitalization beyond stri_trans_totitle that include:

  1. Capitalize the first & last word
  2. Lowercase articles, coordinating conjunctions, & prepositions
  3. Lowercase "to" in an infinitive

Examples

y <- c( "I'm liking it but not too much.", "How much are you into it?", "I'd say it's yet awesome yet." ) L(y)
[[1]] [1] "i'm liking it but not too much." [[2]] [1] "how much are you into it?" [[3]] [1] "i'd say it's yet awesome yet."
U(y)
[[1]] [1] "I'M LIKING IT BUT NOT TOO MUCH." [[2]] [1] "HOW MUCH ARE YOU INTO IT?" [[3]] [1] "I'D SAY IT'S YET AWESOME YET."
TC(y)
[[1]] [1] "I'm Liking It but Not Too Much." [[2]] [1] "How Much Are You into It?" [[3]] [1] "I'd Say It's yet Awesome Yet."