capitalize.Rd
Capitalizes/decapitalized (making the first letter upper/lower case) of each character string in a vector.
# S3 method for default
capitalize(str, ...)
# S3 method for default
decapitalize(str, ...)
words <- strsplit("Hello wOrld", " ")[[1]]
cat(paste(toupper(words), collapse=" "), "\n") # "HELLO WORLD"
#> HELLO WORLD
cat(paste(tolower(words), collapse=" "), "\n") # "hello world"
#> hello world
cat(paste(capitalize(words), collapse=" "), "\n") # "Hello WOrld"
#> Hello WOrld
cat(paste(decapitalize(words), collapse=" "), "\n") # "hello wOrld"
#> 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")