capitalize
From R.utils v1.19.3
by Henrik Bengtsson
Capitalizes/decapitalizes each character string in a vector
Capitalizes/decapitalized (making the first letter upper/lower case) of each character string in a vector.
- Keywords
- programming
Usage
## S3 method for class 'default':
capitalize(str, ...)
## S3 method for class 'default':
decapitalize(str, ...)
Arguments
Value
See Also
Examples
words <- strsplit("Hello wOrld", "")[[1]];
cat(paste(toupper(words), collapse=""), "") # "HELLO WORLD"
cat(paste(tolower(words), collapse=""), "") # "hello world"
cat(paste(capitalize(words), collapse=""), "") # "Hello WOrld"
cat(paste(decapitalize(words), collapse=""), "") # "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")
Community examples
Looks like there are no examples yet.