Factors

module 5
week 9
collapse
factors
labels
levels
recode
Work with categorical variables (factors)
Author

Jeff Stevens

Published

March 20, 2023

We often work with categorical variables, and R coerces them into a special data type called a factor. Factors are augmented integers with levels and labels.

Learning objectives

  • Check levels of factors
  • Reorder factor levels
  • Recode factor labels

Pre-meeting

To prepare for this class meeting, please do the following:

Class meeting

  • Creating factors and checking levels
  • Reordering levels in order of frequency, presence in the vector, or reverse order
  • Recoding factor labels
  • Collapseing and lumping factor labels
  • Slides and Code

Homework after the class meeting

Wrap up this lesson

For next class meeting