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
11. Customizing NAs
Modifying factor variables
Summary

Instruction

What's more, we can give the NA level a customized name, like "unknown". We simply add the name as a second argument to the fct_explicit_na() function:

survey$age <- fct_explicit_na(survey$age, "unknown")

Exercise

Use fct_explicit_na() on mrt_status. Change the default NA level to "unknown". Assign the result to the marital_status variable. Then, use fct_count() to get the number of unknown values.

Stuck? Here's a hint!

Type:

marital_status <- fct_explicit_na(survey\$mrt_status, "unknown")
fct_count(marital_status)