capitalize | R Documentation |
Capitalizes/decapitalized (making the first letter upper/lower case) of each character string in a vector.
## Default S3 method:
capitalize(str, ...)
## Default S3 method:
decapitalize(str, ...)
str |
A |
... |
Not used. |
Returns a vector
of character
strings of the same length as the input
vector.
Henrik Bengtsson
toCamelCase
.
words <- strsplit("Hello wOrld", " ")[[1]]
cat(paste(toupper(words), collapse=" "), "\n") # "HELLO WORLD"
cat(paste(tolower(words), collapse=" "), "\n") # "hello world"
cat(paste(capitalize(words), collapse=" "), "\n") # "Hello WOrld"
cat(paste(decapitalize(words), collapse=" "), "\n") # "hello wOrld"
# Sanity checks
stopifnot(paste(toupper(words), collapse=" ") == "HELLO WORLD")
stopifnot(paste(tolower(words), collapse=" ") == "hello world")
stopifnot(paste(capitalize(words), collapse=" ") == "Hello WOrld")
stopifnot(paste(decapitalize(words), collapse=" ") == "hello wOrld")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.