Skip to contents

Creates a data dictionary for a data set that originally had special characters as variable names.

Usage

create_dict(x, out = NULL)

Arguments

x

A named object.

out

Either a path to a file, a connection, or literal data (either a single string or a raw vector) to export the data dictionary. The default is NULL, which does not result in the creation of data dictionary.

Value

If the out parameter is NULL then only character vector with the new variable names is returned.

Details

The x must be a named object as the main purpose of this function is create a data dictionary for a data set that has special characters in the variable names.

Every time this function is executed the named object x alters the names to remove special character. When the out parameter is specified then a data dictionary is created with the original and new variable names. The current version of this function adjusts for special characters such as spaces, "-", "/", "%", and "#". The naming convention used follows the Tidyverse style guide.

Examples

y <- 1:4
names(y) <- c("a/a", "b-b", "%c", "d#")
names(y) <- create_dict(y)