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

Instruction

Interesting—calculating the average of yard_area simply returned NA. That's not very helpful!

Missing values are tricky and often cause lots of problems in data analysis because you cannot perform standard operations on them. A missing value isn't even a value to begin with! Thus, any operations involving missing values cannot be fully determined.

Relational operators will not work as you might expect with NA. For example, the condition

NA > 5
will neither return TRUE nor FALSE. Rather, it will return NA because R doesn't know how to compare an unknown value ( NA) with the number 5.

Keep in mind that R will not throw an error or give you a warning in such cases—it will simply return NA. Thus, it's important to examine your data ahead of time before performing any calculations so you know if you'll be dealing with missing values.

Exercise

Try filtering the houses data frame to display only those properties that have more than 500 squares of yard surface.

Stuck? Here's a hint!

The information about yard surface is stored in the yard_area column. In order to filter the data frame, you have to write a condition inside the square brackets:

houses[houses$yard_area > 500, ]