D.1 Chapter 1 Solutions
(LC1.1) Repeat the above installing steps, but for the
knitr packages. This will install the earlier mentioned
dplyr package, the
nycflights13 package containing data on all domestic flights leaving a NYC airport in 2013, and the
knitr package for writing reports in R.
(LC1.2) “Load” the
knitr packages as well by repeating the above steps.
Solution: If the following code runs with no errors, you’ve succeeded!
(LC1.3) What does any ONE row in this
flights dataset refer to?
- A. Data on an airline
- B. Data on a flight
- C. Data on an airport
- D. Data on multiple flights
Solution: This is data on a flight. Not a flight path! Example:
- a flight path would be United 1545 to Houston
- a flight would be United 1545 to Houston at a specific date/time. For example: 2013/1/1 at 5:15am.
(LC1.4) What are some examples in this dataset of categorical variables? What makes them different than quantitative variables?
Solution: Hint: Type
?flights in the console to see what all the variables mean!
flightthe flight number. Even though this is a number, its simply a label. Example United 1545 is not less than United 1714
distancethe distance in miles
(LC1.5) What properties of the observational unit do each of
tzone describe for the
airports data frame? Note that you may want to use
?airports to get more information.
long represent the airport geographic coordinates,
alt is the altitude above sea level of the airport (Run
airports %>% filter(faa == "DEN") to see the altitude of Denver International Airport),
tz is the time zone difference with respect to GMT in London UK,
dst is the daylight savings time zone, and
tzone is the time zone label.
(LC1.6) Provide the names of variables in a data frame with at least three variables in which one of them is an identification variable and the other two are not. In other words, create your own tidy dataset that matches these conditions.
- In the
weatherexample in LC2.8, the combination of
hourare identification variables as they identify the observation in question.
- Anything else pertains to observations: