Resulting names are unique and consist only of the _ character, numbers, and letters. 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".

This function takes and returns a data.frame, for ease of piping with `%>%`. For the underlying function that works on a character vector of names, see make_clean_names.

clean_names(dat, case)

# S3 method for default
clean_names(dat, case = c("snake", "lower_camel",
  "upper_camel", "screaming_snake", "lower_upper", "upper_lower",
  "all_caps", "small_camel", "big_camel", "old_janitor", "parsed", "mixed",
  "none"))

Arguments

dat

the input data.frame.

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

  • old_janitor: legacy compatibility option to preserve behavior of clean_names prior to addition of the "case" argument(janitor versions <= 0.3.1 ). Provided as a quick fix for old scripts broken by the changes to clean_names in janitor v1.0.

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

Value

Returns the data.frame with clean names.

Examples

# not run: # clean_names(poorly_named_df) # or pipe in the input data.frame: # poorly_named_df %>% clean_names() # if you prefer camelCase variable names: # poorly_named_df %>% clean_names(., "small_camel") # not run: # library(readxl) # read_excel("messy_excel_file.xlsx") %>% clean_names()