standardize_column_names {cleanepi} | R Documentation |
Standardize column names of a data frame or linelist
Description
All columns names will be reformatted to use the snakecase. When the
conversion to snakecase does not work as expected, use the keep
and/or
rename
arguments to reformat the column name properly.
Usage
standardize_column_names(data, keep = NULL, rename = NULL)
Arguments
data |
The input data frame or linelist. |
keep |
A vector of column names to maintain as they are. When dealing
with a linelist, this can be set to |
rename |
A named vector of column names to be renamed. This should be in
the form of |
Value
A data frame or linelist with easy to work with column names.
Examples
# do not rename 'date.of.admission'
cleaned_data <- standardize_column_names(
data = readRDS(system.file("extdata", "test_df.RDS",
package = "cleanepi")),
keep = "date.of.admission"
)
# do not rename 'date.of.admission', but rename 'dateOfBirth' and 'sex' to
# 'DOB' and 'gender' respectively
cleaned_data <- standardize_column_names(
data = readRDS(system.file("extdata", "test_df.RDS",
package = "cleanepi")),
keep = "date.of.admission",
rename = c(DOB = "dateOfBirth", gender = "sex")
)
[Package cleanepi version 1.0.2 Index]