recodeVariable: Recode Categorical Variables

Description Usage Arguments Value Author(s) Examples

View source: R/recodeVariable.R

Description

Automatically recode a categorical text variable with the help of the data dictionary.

Usage

1
recodeVariable(varName, varVect, dataDict)

Arguments

varName

The name of the categorical variable to be recoded.

varVect

The vector of responses for the specified variable.

dataDict

The "Categories" sheet of the data dictionary produced by Opal. The data dictionary is an Excel spreadsheet that contains the two following sheets: "Variables" and "Categories".

Value

Returns a recoded vector of the categorical variable. Note that if the function replaces entries by NA, then the data dictionary is incomplete for the specified variable.

Author(s)

Phil Boileau, philippe.boileau (at) rimuhc.ca

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
library(xlxs)

dataSet <- read.csv("path_to_file.csv")
dataDict <- read.xlsx("path_to_data_dictionary.xlsx", sheetName = "Categories")

recodeVariable(varName = "countryOfBirth",
              varVect = cobVect,
              dataDict = dictionary.df)

## End(Not run)

gevamaimon/CLSAR documentation built on May 17, 2019, 1:53 p.m.