This is useful for when the user wants to use the columns in a presentation. Shiny, Power BI, and RMarkdown are use cases where we may want clean column names for the user to read.

snake_to(object, format = "title", acronyms = NULL, names_only = FALSE)

Arguments

object

A data.frame, ggplot or character vector object. A data.frame will have transformed column names. A ggplot object will have transformed X and Y axes. A character vector will have clean character names.

format

A string. The desired target (default is "title") case with options including:

  • title: produces title case

  • lower: produces lower case

  • normal: do not transform the string

  • sentence: produces sentence case

  • upper: produces upper case

acronyms

A Character. Default NULL. For when acronyms exist in the column names that need to be capitalized. Pass a character vector for when there is more than one acronym. Upper and/or lower case acronyms in this parameter will be accepted. This will only capitalize the wanted words, words that may contain the acronyms letter will NOT be capitalized.

names_only

A Logical. Default FALSE. If TRUE, snake_to() will return a vector of transformed column names.

Value

Returns a data.frame with clean names, a ggplot object with clean axes, or a vector of clean strings.

Examples

if (FALSE) { # snake to title .data %>% snake_to() # snake to sentence .data %>% snake_to(format = "sentence") # snake to title, keep vector of transformed column names .data %>% snake_to(names_only = TRUE) # snake to title, capitalize acronyms acronyms <- c("pyr", "cyr") .data %>% snake_to(acronyms = acronyms) }