Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
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"))