Homework 4

Key

Click link above for answers to homework 4.

Instructions

Answer each of the following questions. Be sure to display all your code in the rendered version (use echo: true throughout1).

Remember, the package nycflights13 contains data on flights originating in NYC during the year 2013. There are three airports servicing NYC: JFK, LGA (“LaGuardia”), and EWR (“Newark”).

Exercises

  1. Choose an airport outside New York, and count how many flights went to that airport from NYC in 2013. How many of those flights started at JFK, LGA, and EWR respectively?

  2. The variable arr_delay contains arrival delays in minutes (negative values represent early arrivals). Make a ggplot histogram displaying arrival delays for 2013 flights from NYC to the airport you chose.

  1. Use left_join to add weather data at departure to the subsetted data. If time_hour didn’t exist in one or both of these datasets, which variables would you need to merge on? Calculate the mean temperature by month at departure (temp) across all flights.
  1. Investigate if there is a relationship between departure delay (dep_delay) and precipitation (precip) in the full dataset. Is the relationship different between JFK, LGA, and EWR? I suggest answering this question by making a plot and writing down a one-sentence interpretation2.

As always, submit both the .qmd and knitted .html to Canvas.

Before you submit:

Have you remembered to add embed-resources: true to your YAML?

Due Dates

# Homework Due Peer Review Due
1 2 April 7 April
2 9 April 14 April
3 16 April 21 April
4 23 April 28 April
5 30 April 5 May
6 7 May 12 May
7 14 May 19 May
8 21 May 26 May
9 28 May 2 June

Footnotes

  1. You can make this a global option for your whole document by putting it directly in the YAML of your qmd:

    ---
    title: "My Document"
    execute:
      echo: true
    ---
    ↩︎
  2. Hint: Read about geom_smooth() and consider how you might use it with the argument method = "lm" to plot a relationship between these two variables.↩︎