snakeToCamel converts "snake-case" characters such as
to "camel-case" values, such as
"NovaScotia". It was written for
read.argo(), but it also may prove helpful in other contexts.
A vector of character values.
A vector of character values that tell which
special-cases to apply, or
The basic procedure is to chop the string up into substrings separated by the underline character, then to upper-case the first letter of all substrings except the first, and then to paste the substrings together.
However, there are exceptions. First, any upper-case string that contains no
underlines is converted to lower case, but any mixed-case string with no
underlines is returned as-is (see the second example). Second, if
specialCases argument contains
"QC", then the
QC is passed through directly (since it is an acronym) and
if the first letter of remaining text is upper-cased (contrast
see the four examples).
A vector of character values
1 2 3 4 5 6 7
library(oce) snakeToCamel("PARAMETER_DATA_MODE") # "parameterDataMode" snakeToCamel("PARAMETER") # "parameter" snakeToCamel("HISTORY_QCTEST") # "historyQctest" snakeToCamel("HISTORY_QCTEST", "QC") # "historyQCTest" snakeToCamel("PROFILE_DOXY_QC") # "profileDoxyQc" snakeToCamel("PROFILE_DOXY_QC", "QC") # "profileDoxyQC"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.