Homework 4

Instructions

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

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
---

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.

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.

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 7 October 12 October
2 14 October 19 October
3 21 October 26 October
4 28 October 2 November
5 11 November 16 November
6 18 November 23 November
7 25 November 30 November
8 2 December 7 December
9 9 December 14 December