capitalize

0th

Percentile

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
str
A vector of character strings to be capitalized.
...
Not used.
Value

  • Returns a vector of character strings of the same length as the input vector.

See Also

toCamelCase.

Aliases
  • capitalize.default
  • capitalize
  • decapitalize
  • decapitalize.default
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")
Documentation reproduced from package R.utils, version 1.28.4, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.