Learn R Programming

R.utils (version 1.9.7)

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

Description

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

Usage

## S3 method for class 'default':
toCamelCase(s, capitalize=FALSE, split="[ 	]+", ...)

Arguments

s
A character string.
capitalize
If TRUE, the first letter will be in upper case, otherwise it will be in lower case.
split
A pattern used to identify words. See strsplit() for more details.
...
Not used.

Value

See Also

capitalize. chartr().

Examples

Run this code
s <- "hello world"
print(toCamelCase(s))  # helloWorld
print(toCamelCase(s, capitalize=TRUE))  # HelloWorld
stopifnot(toCamelCase(s) == toCamelCase(toCamelCase(s)))

Run the code above in your browser using DataLab