When variables have numerical levels it is necessary to ensure that the program knows it is a factor variable.
The following code uses the
factor() function to take the marital status variable and convert it into a factor variable with specified labels that match the codebook.
It is important to confirm the recode worked. If it did not you will have to re-read in the raw data set again since the variable
marital was replaced.
See more examples on Math 130 Lesson 06