clean_variable_names: Clean variable names

View source: R/clean_variable_names.R

clean_variable_namesR Documentation

Clean variable names

Description

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.

Usage

clean_variable_names(x, protect = FALSE, ...)

Arguments

x

a data.frame

protect

a logical or numeric vector specifying which columns to protect from manipulation

...

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 variable names.

Author(s)

Thibaut Jombart

See Also

clean_data() for a one-shot wrapper to clean your data

Examples


## 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


## clean variable names, store in new object, show results
clean_data <- clean_variable_names(toy_data)
clean_data

reconhub/linelist documentation built on Jan. 1, 2023, 9:39 p.m.