CLiREN-LMS
Data Cleaning and Preparation in R

Recoding Categorical Variables

Table 1

30-45 minutes Applied Step 6 of 10
Table

Table 1

6 / 10
Table

Table 1

Recoding situationExamplePreferred practice
Numeric codes to labels`1`, `2`, `3` to sex labelsUse data dictionary and preserve original variable
Text standardization`done`, `Complete`, `completed`Create cleaned variable and review free text source
Unexpected valuesCode `9` appears but is not definedFlag for review rather than silently dropping
Checkbox variablesMultiple binary columns for symptomsKeep raw checkbox fields and derive summary variables
Site names`Kilifi`, `Kilifi Hosp`, `KWTRP`Use controlled site lookup table