[R] how to transform string to "Camel Case"?

Pascal Oettli kridox at ymail.com
Mon Apr 15 09:20:33 CEST 2013


Hi,

There is an example of how to do do what you are looking for in ?toupper

Regards,
Pascal

On 04/15/2013 03:50 PM, Liviu Andronic wrote:
> Dear all,
> Given the following vector:
>> (z <- c('R project', 'hello world', 'something Else'))
> [1] "R project"      "hello world"    "something Else"
>
> I know how to obtain all capitals or all lower case letters:
>> tolower(z)
> [1] "r project"      "hello world"    "something else"
>> toupper(z)
> [1] "R PROJECT"      "HELLO WORLD"    "SOMETHING ELSE"
>
> I saw the tocamel() function in 'rapport', but it doesn't do what I
> want to achieve as it actually proceeds to camelCase/CamelCase the
> strings:
>> tocamel(z)
> [1] "RProject"      "helloWorld"    "somethingElse"
>
>
> But how should I proceed to obtain Camel Case? Here's what I'd like to get:
> c('R Project', 'Hello World', 'Something Else')
>
>
> Regards,
> Liviu
>
>



More information about the R-help mailing list