Exercises
A useful question we might want to ask is the following: Are longitude and latitude mostly missing as pairs? In other words, is it generally the case that when longitude is missing, so is latitude and vice versa?
Once missing values are formatted as NAs, we use the is.na
function to determine what's an NA.
is.na(c(2, 4, NA, -1, 5, NA))
Combine is.na
and table
to answer the following question:
(1) How many of the pickup_longitude
values are NAs? (This was also answered when we ran summary
.)
(2) How many times are pickup_longitude
and pickup_latitude
missing together vs separately?
(3) Of the times when the pair pickup_longitude
and pickup_latitude
are missing, how many times is the pair dropoff_longitude
and dropoff_latitude
also missing?