End of Summer - hours only!Up to 80% off on all courses and bundles.-Close


We are getting the result that these age values are all 999. That's how the survey author saved missing ages. It'd be better if they saved this as a NA but the damage has already been done – we need to correct it. We can do this very simply by using the is.na() function and choosing the right rows. Have a look:

census2017$age[census2017$age==999] <- NA

What we are doing here? We are choosing all rows where the age value is 999 and then replacing the 999 value with NA. Let's correct the 2018's data in the same way!


Recode the missing values in the census2018's age column to NA.