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

Instruction

Great! In previous exercises, you learned how to check how many values are missing from a column. You also learned how to identify which rows contain NAs under specific columns. Now, let's go a little bit further.

If you assume that the yard_area column is not populated for houses that have no yards, you can detect NA values as usual. However, you can also replace these NAs with some other value, such as 0:

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

Exercise

The parking_places_no column denotes how many parking places a property has. This column has some missing values. Assume that a missing value means that there are zero parking places for this property. Replace all NAs in this column with 0.

Stuck? Here's a hint!

You should filter the rows that have the NA value, and then assign 0 to them:

houses[is.na(houses$parking_places_no),]$parking_places_no <- 0