Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
NAs
Factors
Summary

Instruction

Correct! The process of replacing missing values with other values is called imputation. We replaced (imputed) the NAs with 0 like so:

houses[is.na(houses\$yard_area), "yard_area"] <- 0

When you impute a missing value you want to replace it with the most probable value. The method you use depends on how you choose to interpret a missing value. Sometimes, an NA may mean 0. Other times it may be represented with an average, median or maximum. Sometimes, however, NA means just that - NA.

Exercise

Replace all missing values under the yard_area column with the average value of that column.

Stuck? Here's a hint!

Remember to remove the NA values when calculating the mean. Set the na.rm argument to TRUE:

mean(..., na.rm=TRUE)