toCamelCase

0th

Percentile

Converts a string of words into a merged camel-cased word

Converts a string of words into a merged camel-cased word, e.g. "a single espresso" is converted to "aSingleEspresso".

Keywords
internal, programming, IO
Usage
## S3 method for class 'default':
toCamelCase(s, capitalize=FALSE, preserveSameCase=FALSE, split="[ \t]+", ...)
Arguments
s
A character string.
capitalize
If TRUE, the first letter will be in upper case, otherwise it will be in lower case.
preserveSameCase
If TRUE, words that are in all upper case will remain as all same case words, e.g. acronyms.
split
A pattern used to identify words. See strsplit() for more details.
...
Not used.
Value

See Also

capitalize. chartr().

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

Community examples

Looks like there are no examples yet.