case | R Documentation |
Convert a text string to several common cases.
case(
x,
case = c("first", "upcase", "downcase", "camelcase", "upper", "lower", "lowup",
"uplow"),
translate = FALSE
)
x |
a text string |
case |
a case to use; can be (unambiguously) abbreviated; see details |
translate |
logical; if |
This function supports the following letter cases:
first | Only the first letter is uppercase |
|
upcase | Each Word Is Uppercase |
|
downcase | tHE oPPOSITE oF uPCASE |
|
camelcase | TheStringWillBeInCamelCase |
|
upper | EQUIVALENT TO toupper |
|
lower | equivalent to tolower |
|
lowup | aLtErNaTiNg cAsEs |
|
uplow | ThE OpPoSiTe oF LoWuP |
|
cases <- eval(formals(case)$case)
x <- 'the quick brown fox'
sapply(cases, case, x = x)
## all cases are vectorized
sapply(cases, case, x = strsplit(x, ' ')[[1]])
case('upCASE', 'upcase', translate = FALSE) ## default
case('upCASE', 'upcase', translate = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.