format_names | R Documentation |
This function can be used on any data.frame
, list
or character vector to format their names or values. It supports snake case and camel case.
format_names( x, ..., snake_case = FALSE, camelCase = FALSE, tolower = FALSE, toupper = FALSE )
x |
a |
... |
when |
snake_case |
logical to indicate whether the column names must be in snake case. This will have no effect on manually set column names. |
camelCase |
logical to indicate whether the column names must be in camel case. This will have no effect on manually set column names. |
tolower, toupper |
logical to indicate whether the column names must be lower/upper case. This will have no effect on manually set column names. |
df <- data.frame(Name.341ABC = "value", name_123def = "value", This.is.a.column = "value") format_names(df, snake_case = TRUE) format_names(df, camelCase = TRUE) format_names(df, letters[1:3]) format_names(df, This.is.a.column = "a_new_colname") rownames(mtcars) <- format_names(rownames(mtcars), snake_case = TRUE) mtcars[, 1:5] format_names(list(a = 1, b = 2), c("new_1", "new_2")) ## Not run: library(dplyr) starwars %>% format_names(camelCase = TRUE) %>% # new column names mutate(name = name %>% format_names(name, snake_case = TRUE)) # new values in column ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.