Converts a string of words into a merged camel-cased word, e.g. "a single espresso" is converted to "aSingleEspresso".
# S3 method for default
toCamelCase(s, capitalize=FALSE, preserveSameCase=FALSE, split="[ \t]+", ...)
If TRUE
, the first letter will be in upper case,
otherwise it will be in lower case.
If TRUE
, words that are in all upper case
will remain as all same case words, e.g. acronyms.
A pattern used to identify words. See strsplit
()
for more details.
Not used.
capitalize
.
chartr
().
# NOT RUN {
s <- "hello world"
print(toCamelCase(s)) # helloWorld
print(toCamelCase(s, capitalize=TRUE)) # HelloWorld
stopifnot(toCamelCase(s) == toCamelCase(toCamelCase(s)))
s <- "GEO Accession"
print(toCamelCase(s)) # gEOAccession
print(toCamelCase(s, preserveSameCase=TRUE)) # geoAccession
print(toCamelCase(s, capitalize=TRUE)) # GEOAccession
print(toCamelCase(s, capitalize=TRUE, preserveSameCase=TRUE)) # GEOAccession
stopifnot(toCamelCase(s) == toCamelCase(toCamelCase(s)))
# }
Run the code above in your browser using DataLab