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.
Type:
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"))
fct_count(cars$satisfaction)