End of Summer - hours only!Up to 80% off on all courses and bundles.-Close
Factors and how to create them
Working with factors
Modifying factor variables
16. Change factor levels
Summary

## Instruction

Suppose we want to change from the current five levels in statement to only three: Disagree, Neutral, Agree.

To do this, we need to lump all the Strongly Disagree and Somewhat Disagree responses into one response (Disagree). We can use the forcats fct_collapse() function to do this. It collapses the data from one or more levels into a new level. The arguments are the factor variable and the new level name. The levels that will be collapsed to form the new level are listed inside the new level, like this:

survey$simple_stmt <- fct_collapse(survey$statement,
"Disagree" = c("Strongly Disagree", "Somewhat Disagree"))


Let's check the levels of this new factor: