Skip to contents

This function removes digits, spaces, and special characters from a variable name. If any of these are present, they will be replaced with an underscore '_'.

Usage

clean_variable_name(name)

Arguments

name

The input variable name to be cleaned.

Value

The cleaned variable name without digits, spaces, or special characters.

Details

This function will check the input variable name for the presence of digits, spaces, and special characters. If any of these are found, they will be removed from the variable name and replaced with an underscore '_'. Additionally, it will check if the cleaned name is not one of the reserved names "interactions" or "correlations" which are not allowed as variable names.

Examples

clean_variable_name("my_var_12349309spe ")
#> Variable name should not contain digits, spaces, or special characters.
#> If any of these are present, they will be removed from the variable name.
#> [1] "myvarspe"