| autoRecode {eatGADS} | R Documentation |
Auto recode a variable in a GADSdat.
Description
Auto recode a variable in a GADSdat. A look up table is created containing the respective recode pairs.
An existing look up table can be utilized via template. This function somewhat mirrors the functionality provided
by the SPSS function autorecode.
Usage
autoRecode(
GADSdat,
var,
var_suffix = "",
label_suffix = "",
csv_path = NULL,
template = NULL
)
Arguments
GADSdat |
A |
var |
Character string of the variable name which should be recoded. |
var_suffix |
Variable suffix for the newly created |
label_suffix |
Suffix added to variable label for the newly created variable in the |
csv_path |
Path for the |
template |
Existing look up table. |
Details
If an existing template is used and a look up table is saved as a .csv file, the resulting look up
table will contain the existing recodes plus additional recode pairs required for the data.
Value
Returns a GADSdat object.
Examples
gads <- import_DF(data.frame(v1 = letters))
# auto recode without saving look up table
gads2 <- autoRecode(gads, var = "v1", var_suffix = "_num")
# auto recode with saving look up table
f <- tempfile(fileext = ".csv")
gads2 <- autoRecode(gads, var = "v1", var_suffix = "_num", csv_path = f)