On January 21th at 14:15 UTC , progression through exercises will be unavailable for 10 minutes due to a planned maintenance break.
Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
NAs
Summary

Instruction

Great job! Now, if you want to know how many values are missing from a vector, you can use the sum() function, which takes a single vector argument and returns the sum of its elements. When the argument is a logical vector, FALSE is treated as 0, and TRUE is treated as 1.

Thus, by passing in the logical vector returned by is.na() to the sum() function, we can easily determine how many values are missing from the original vector. This corresponds to the number of TRUE values in the logical vector.

Let's use the same vector as in our previous example: a <- c(2, 3, 4, 5, NA, NA). When we invoke

sum(is.na(a))
R returns 2. This is indeed the number of values that are missing from the vector a!

Exercise

How many values are missing from the yard_area column?