This function standardises the variable names in a
data.frame
. It uses the standardisation implemented by
epitrix::clean_labels()
in the epitrix
package. See
?epitrix::clean_labels
for more information.
clean_variable_names(x, protect = FALSE, ...)
x | a |
---|---|
protect | a logical or numeric vector specifying which columns to protect from manipulation |
... | further arguments passed to |
A data.frame
with standardised variable names.
clean_data()
for a one-shot wrapper to clean your data
## make toy data onsets <- as.Date("2018-01-01") + sample(1:10, 20, replace = TRUE) gender <- sample(c("male", "female"), 20, replace = TRUE) case_type <- c("confirmed", "probable", "suspected", "not a case") case <- sample(case_type, 20, replace = TRUE) toy_data <- data.frame("Date of Onset." = onsets, "_GENDER_ " = gender, "Épi.Case_définition" = case) ## show data toy_data#> Date.of.Onset. X_GENDER_. Épi.Case_définition #> 1 2018-01-06 female confirmed #> 2 2018-01-07 female confirmed #> 3 2018-01-08 male probable #> 4 2018-01-11 male confirmed #> 5 2018-01-04 female confirmed #> 6 2018-01-07 female not a case #> 7 2018-01-03 female suspected #> 8 2018-01-11 female confirmed #> 9 2018-01-11 female probable #> 10 2018-01-07 male probable #> 11 2018-01-09 female not a case #> 12 2018-01-04 male probable #> 13 2018-01-10 male confirmed #> 14 2018-01-02 male not a case #> 15 2018-01-02 male not a case #> 16 2018-01-07 male suspected #> 17 2018-01-10 female not a case #> 18 2018-01-10 male suspected #> 19 2018-01-02 male confirmed #> 20 2018-01-07 male probable## clean variable names, store in new object, show results clean_data <- clean_variable_names(toy_data) clean_data#> date_of_onset x_gender epi_case_definition #> 1 2018-01-06 female confirmed #> 2 2018-01-07 female confirmed #> 3 2018-01-08 male probable #> 4 2018-01-11 male confirmed #> 5 2018-01-04 female confirmed #> 6 2018-01-07 female not a case #> 7 2018-01-03 female suspected #> 8 2018-01-11 female confirmed #> 9 2018-01-11 female probable #> 10 2018-01-07 male probable #> 11 2018-01-09 female not a case #> 12 2018-01-04 male probable #> 13 2018-01-10 male confirmed #> 14 2018-01-02 male not a case #> 15 2018-01-02 male not a case #> 16 2018-01-07 male suspected #> 17 2018-01-10 female not a case #> 18 2018-01-10 male suspected #> 19 2018-01-02 male confirmed #> 20 2018-01-07 male probable