# --- Simple Usage ---
x <- data.frame(caseID = 1, DOB = 2, Other = 3)
clean_names(x)
# or pipe in the input data.frame:
x %>%
clean_names()
# if you prefer camelCase variable names:
x %>%
clean_names(., "lower_camel")
# (not run) run clean_names after reading in a spreadsheet:
# library(readxl)
# read_excel("messy_excel_file.xlsx") %>%
# clean_names()
# --- Taking advantage of the underlying snakecase::to_any_case arguments ---
# Restore column names to Title Case, e.g., for plotting
mtcars %>%
clean_names(case = "title")
# Tell clean_names to leave certain abbreviations untouched:
x %>%
clean_names(case = "upper_camel", abbreviations = c("ID", "DOB"))
Run the code above in your browser using DataLab