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


Good job! There's actually a way to remove missing values from (certain) calculations! In particular, when performing calculations with the min(), max(), and mean() functions. These three functions offer an optional na.rm argument, which stands for "NA remove". By default, if the na.rm argument is not specified, R treats it as FALSE. By manually setting na.rm to TRUE, you can tell R to remove NA values from a vector prior to performing any calculations on it.

Note that this does not remove NAs from the original vector. It simply removes them from the calculation.

Consider the same a vector that we saw before: a <- c(2, 3, 4, 5, NA, NA). The function call

will return 2. The vector a will remain unchanged after these calls. The max() and mean() functions work in the same way.


Calculate the average value of the yard_area column. Recall that some values are missing from this column, so you'll need to tell R to remove any NAs it encounters before performing any calculations.

Stuck? Here's a hint!

You should use the mean() function with the additional argument na.rm=TRUE.