clean_string: Cleans character strings

Description Usage Arguments Value Examples

Description

This is a variant on clean_names. It produces strings that consist only of the _ character, numbers, and letters. It differs from its parent function in that it neither avoids duplicates nor strings starting with a numeral. Capitalization preferences can be specified using the case parameter.

Accented characters are transliterated to ASCII. For example, an "o" with a German umlaut over it becomes "o", and the Spanish character "enye" becomes "n".

Usage

1
2
3
4
5
clean_string(
  string,
  case = c("snake", "lower_camel", "upper_camel", "screaming_snake", "lower_upper",
    "upper_lower", "all_caps", "small_camel", "big_camel", "parsed", "mixed")
)

Arguments

string

the input string.

case

The desired target case (default is "snake"), indicated by these possible values:

  • "snake" produces snake_case

  • "lower_camel" or "small_camel" produces lowerCamel

  • "upper_camel" or "big_camel" produces UpperCamel

  • "screaming_snake" or "all_caps" produces ALL_CAPS

  • "lower_upper" produces lowerUPPER

  • "upper_lower" produces UPPERlower

  • "parsed", "mixed", "none": less-common cases offered by snakecase::to_any_case. See to_any_case for details.

Value

Returns the clean string.

Examples

1
2
# not run:
# clean_string(" Þetta: er hræðilegur textastrengur")

hlynurhallgrims/hlynur documentation built on Dec. 23, 2019, 6:37 p.m.