Learn R Programming

eatGADS (version 1.0.0)

autoRecode: 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, suffix = "", csv_path = NULL, template = NULL)

Value

Returns a GADSdat object.

Arguments

GADSdat

A GADSdat object.

var

Character string of the variable name which should be sorted.

suffix

Character string of the variable suffix.

csv_path

Path for the .csv file for the look up table.

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.

Examples

Run this code
gads <- import_DF(data.frame(v1 = letters))

# auto recode without saving look up table
gads2 <- autoRecode(gads, var = "v1", suffix = "_num")

# auto recode with saving look up table
f <- tempfile(fileext = ".csv")
gads2 <- autoRecode(gads, var = "v1", suffix = "_num", csv_path = f)

Run the code above in your browser using DataLab