Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
Factors and how to create them
Working with factors
Modifying factor variables
23. Exercise 4


Surely there were some missing answers in the satisfaction column. Let's see them!


Change the satisfaction level NA to "unknown" using fct_explicit_na(). Assign it to the satisfaction column of the cars dataset.

Recode the levels so that there are only these levels: Neutral, Satisfied, Dissatisfied, and unknown. Use fct_collapse().

Use fct_count() on the satisfaction column to count the new satisfaction levels.

Stuck? Here's a hint!


cars$satisfaction <- fct_explicit_na(cars$satisfaction, "unknown")

cars$satisfaction <- fct_collapse(cars$satisfaction,
  "Dissatisfied" = c(
    "Moderately dissatisfied",
    "Slightly dissatisfied"),
  "Satisfied"    = c(
    "Very satisfied",
    "Moderately satisfied",
    "Slightly satisfied"))