Chapter 12: Logical vectors

Set up

We have already loaded the R packages you need for this tutorial. Once you start working in RStudio, you will run code like the code shown below to load the R packages you need.

Exercises

All exercises are from R for Data Science 2nd Edition.

Ex 1 in Section 12.2.4

How does near() in dplyr package work? Type near to see the source code. Is sqrt(2)^2 near 2?

More about floating point comparison can be found in section 12.2.1.

Ex 1 in Section 12.3.4

Find all flights where arr_delay is missing but dep_delay is not. Find all flights where neither arr_time nor sched_arr_time are missing, but arr_delay is.

Open code chunk

Here is a code chunk in case you wish to play around with some code