This function standardises the labels of all characters of factors 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_labels(x, classes = NULL, ...)

Arguments

x

a data.frame

classes

a vector of class definitions for each of the columns. If this is not provided, the classes will be read from the columns themselves. Practically, this is used in clean_data() to mark columns as protected.

...

further arguments passed to epitrix::clean_labels(); the most important is sep, which refers to the separator used between words, and defaults to the underscore _.

Value

A data.frame with standardised labels for characters and factors.

Examples

## make toy data toy_data <- clean_variable_names(messy_data()) ## clean variable labels, store in new object, show results clean_data <- clean_variable_labels(toy_data) clean_data
#> id date_of_onset discharge gender epi_case_definition messy_dates #> 1 nitoug 2018-01-05 15_01_2018 male suspected that_s_24_12_1989 #> 2 zrubxe 2018-01-07 17_01_2018 male probable male #> 3 tcdawa 2018-01-07 17_01_2018 female probable 2018_10_18 #> 4 uvzwsh 2018-01-02 12_01_2018 male probable 2018_10_17 #> 5 wbqqij 2018-01-04 14_01_2018 female confirmed <NA> #> 6 cknjtx 2018-01-02 12_01_2018 female probable 2018_10_17 #> 7 hemwka 2018-01-10 20_01_2018 male not_a_case <NA> #> 8 rnihsr 2018-01-02 12_01_2018 female not_a_case 2018_10_18 #> 9 tesaao 2018-01-11 21_01_2018 female not_a_case 2018_10_19 #> 10 sytcqa 2018-01-03 13_01_2018 male probable 2018_10_18 #> 11 xtvmnz 2018-01-09 19_01_2018 female probable <NA> #> 12 bagtwl 2018-01-11 21_01_2018 female not_a_case 2018_10_19 #> 13 cqwsng 2018-01-11 21_01_2018 female not_a_case 2018_10_19 #> 14 wgoncb 2018-01-02 12_01_2018 female confirmed that_s_24_12_1989 #> 15 valtgd 2018-01-05 15_01_2018 male suspected 24_12_1989 #> 16 knpgqn 2018-01-10 20_01_2018 female suspected 24_12_1989 #> 17 kvjkyb 2018-01-02 12_01_2018 female not_a_case male #> 18 yiqkas 2018-01-03 13_01_2018 female not_a_case 2018_10_18 #> 19 cpjyeh 2018-01-04 14_01_2018 male not_a_case 2018_10_18 #> 20 cmnpla 2018-01-03 13_01_2018 male probable 24_12_1989 #> lat lon #> 1 14.64411 46.70684 #> 2 14.40728 48.75475 #> 3 12.68457 47.73267 #> 4 12.64639 48.64208 #> 5 15.84507 47.58267 #> 6 10.36658 46.78294 #> 7 12.87732 50.13236 #> 8 13.19119 46.91052 #> 9 11.91412 48.11649 #> 10 13.99691 49.26118 #> 11 12.91624 49.04062 #> 12 13.99174 47.03056 #> 13 14.80186 48.39073 #> 14 16.23876 48.60770 #> 15 13.75793 47.00237 #> 16 12.66217 49.19711 #> 17 11.91513 46.22732 #> 18 10.09231 48.78484 #> 19 13.36070 47.56266 #> 20 13.99578 47.64826