Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Factors and how to create them
Working with factors
9. Factors and NA values
Modifying factor variables


Often, there are missing values in our data (e.g., people don't answer every question in a survey). The problem with NAs is that some R functions won't include NA values at all in their result.

How can we inform R that we want to know about the missing information? We can use the fct_explicit_na() function, which adds a new level (named "(Missing)") and changes NA values to that level.

Let's change the NA values in the age column:

survey$age <- fct_explicit_na(survey$age)


Use fct_explicit_na() on the mrt_status column from survey. Assign the result to the same column.

Stuck? Here's a hint!


survey$mrt_status <- fct_explicit_na(survey$mrt_status)