R: Specific case converter shortcuts

caseconverter {snakecase} | R Documentation

## Specific case converter shortcuts

### Description

Wrappers around `to_any_case()`

### Usage

    to_snake_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
      parsing_option = 1, transliterations = NULL, sep_out = NULL,
      unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")

    to_lower_camel_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
      parsing_option = 1, transliterations = NULL, sep_out = NULL,
      unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")

    to_upper_camel_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
      parsing_option = 1, transliterations = NULL, sep_out = NULL,
      unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")

    to_screaming_snake_case(string, abbreviations = NULL,
      sep_in = "[^[:alnum:]]", parsing_option = 1, transliterations = NULL,
      sep_out = NULL, unique_sep = NULL, empty_fill = NULL, prefix = "",
      postfix = "")

    to_parsed_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
      parsing_option = 1, transliterations = NULL, sep_out = NULL,
      unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")

    to_mixed_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
      parsing_option = 1, transliterations = NULL, sep_out = NULL,
      unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")

    to_lower_upper_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
      parsing_option = 1, transliterations = NULL, sep_out = NULL,
      unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")

    to_upper_lower_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
      parsing_option = 1, transliterations = NULL, sep_out = NULL,
      unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")

    to_swap_case(string, abbreviations = NULL, sep_in = "[^[:alnum:]]",
      parsing_option = 1, transliterations = NULL, sep_out = NULL,
      unique_sep = NULL, empty_fill = NULL, prefix = "", postfix = "")

### Arguments

`string` | A string (for example names of a data frame).
`abbreviations` | character with (uppercase) abbreviations. This marks abbreviations with an underscore behind (in front of the parsing). Useful if `parsing_option` 1 is needed, but some abbreviations within the string need `parsing_option` 2. Use this feature with care: One letter abbreviations and abbreviations next to each other may not be handled correctly, since those cases would introduce ambiguity in parsing.
`sep_in` | (short for separator input) if character, is interpreted as a regular expression (wrapped internally into `stringr::regex()`). The default value is a regular expression that matches any sequence of non-alphanumeric values. All matches will be replaced by underscores (additionally to `"_"` and `" "`, for which this is always true, even if `NULL` is supplied). These underscores are used internally to split the strings into substrings and specify the word boundaries.
`parsing_option` | An integer that will determine the parsing_option. 1: `RRRStudio -> RRR_Studio` 2: `RRRStudio -> RRRS_tudio` 3: This `parsing_option` will suppress the conversion after non-alphanumeric values. See examples. 4: digits directly behind/in front non-digits, will stay as is. any other integer <= 0: no parsing"
`transliterations` | A character vector (if not `NULL`). The entries of this argument need to be elements of `stringi::stri_trans_list()` (like "Latin-ASCII", which is often useful) or names of lookup tables (currently only "german" is supported). In the order of the entries the letters of the input string will be transliterated via `stringi::stri_trans_general()` or replaced via the matches of the lookup table. You should use this feature with care in case of `case = "parsed"`, `case = "internal_parsing"` and `case = "none"`, since for upper case letters, which have transliterations/replacements of length 2, the second letter will be transliterated to lowercase, for example Oe, Ae, Ss, which might not always be what is intended.
`sep_out` | (short for separator output) String that will be used as separator. The defaults are `"_"` and `""`, regarding the specified `case`.
`unique_sep` | A string. If not `NULL`, then duplicated names will get a suffix integer in the order of their appearance. The suffix is separated by the supplied string to this argument.
`empty_fill` | A string. If it is supplied, then each entry that matches "" will be replaced by the supplied string to this argument.
`prefix` | prefix (string).
`postfix` | postfix (string).

### Value

A character vector according the specified parameters above.

A character vector according the specified target case.

### Note

caseconverters are vectorised over `string`, `sep_in`, `sep_out`, `empty_fill`, `prefix` and `postfix`.

### Author(s)

Malte Grosser, malte.grosser@gmail.com

Malte Grosser, malte.grosser@gmail.com

### See Also

snakecase on github, `to_any_case` for flexible high level conversion and more examples.

### Examples

    strings <- c("this Is a Strange_string", "AND THIS ANOTHER_One", NA)

    to_snake_case(strings)
    to_lower_camel_case(strings)
    to_upper_camel_case(strings)
    to_screaming_snake_case(strings)
    to_lower_upper_case(strings)
    to_upper_lower_case(strings)
    to_parsed_case(strings)
    to_mixed_case(strings)
    to_swap_case(strings)

[Package snakecase version 0.9.1 Index]