e_REDCap_use_dotfactor_var: REDCap data, use ".factor" var with original variable label

View source: R/e_REDCap_use_dotfactor_var.R

e_REDCap_use_dotfactor_varR Documentation

REDCap data, use ".factor" var with original variable label

Description

For the factor (categorical) variables, the non-".factor" variable name is a numeric class with the levels (and a variable label) while the ".factor" variable name is a factor class with the labels in the appropriate order (and no variable label). This function copies the variable label from the non-".factor" variable name to the ".factor" variable, then copies the ".factor" variable to the non-".factor" variable name. This makes the non-".factor" variable name have all the best attributes. Finally, drop all the ".factor" variables from the data.

Usage

e_REDCap_use_dotfactor_var(dat, var_names = NULL, sw_all_dotfactor = TRUE)

Arguments

dat

data.frame file to process

var_names

non-".factor" variable names to update

sw_all_dotfactor

T/F to process all ".factor" variables

Value

dat with updated non-".factor" variables

Examples

## Not run: 
# dat_temp <-
#   e_REDCap_use_dotfactor_var(
#     var_names = c("labs_bun_hl", "labs_cr_hl", "labs_elec_na_hl")
#   , dat       = dat_vci
#   )

## End(Not run)

erikerhardt/erikmisc documentation built on April 17, 2025, 10:48 a.m.