---
title: "Comp/Stat 112: Exploratory Data Analysis"
author: "INSERT STUDENT NAME HERE (COLLABORATOR NAMES HERE)"
output:
  bookdown::html_document2:
    split_by: none
    toc: yes
    toc_depth: 3
    toc_float:
      toc_collapsed: true
    number_sections: false
---

```{r 12_setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, error = TRUE)
library(tidyverse)
library(ggplot2)
library(lubridate)
library(ggmap)
library(GGally)
```

# Exploratory Data Analysis

## Practice: Flight Data {-}

Let's practice these steps using data about [flight delays from Kaggle](https://www.kaggle.com/usdot/flight-delays). You have access to the data for airlines, airports, and flights.

There are three tables of data:


```{r, cache=TRUE}
airlines <- read_csv("https://bcheggeseth.github.io/112_fall_2022/data/airlines.csv")
airports <- read_csv("https://bcheggeseth.github.io/112_fall_2022/data/airports.csv")
flights <- read_csv("https://bcheggeseth.github.io/112_fall_2022/data/flights_jan_jul_sample2.csv")
```

Note that the full set of flight data has more than 5.8 million flights. To start, I have given you a subset that includes all flights in the first 15 days of January 2015 and in the first 15 days of July 2015. If at the end you wish to try your analysis on the whole data set, you can download the original .csv file from the Kaggle page and substitute a link to it in the code chunk above.


There is a ton of data here, and it can be easy to be overwhelmed. We are going to focus our exploration a bit by considering the following broad research question: **which flights are most likely to be delayed?**

```{exercise, name="Data source"}
Where does this data come from? Who collected it?   
```

> ANSWER:



```{exercise, name="Explore codebook"}
This data set comes with a codebook on the Kaggle site. Have a look at the codebook to understand which variables are contained in each of the three tables. For example, what are the levels of `CANCELLATION_REASON` and what do they mean? What is the unit of observation for each table?

```

> ANSWER:

```{exercise, name="Possible joins"}
What variables link the three tables? How could you join data from one table to another?
  
```

> ANSWER:


```{exercise, name="Visualize and describe the data"}
Use some univariate and bivariate visualizations to start to explore the questions mentioned above:

* What do you see that is interesting? 
* Which values are most common or unusual (outliers)?
* Is there a lot of missing data?
* What type of variation occurs within the individual variables?
* What might be causing the interesting findings?
* How could you figure out whether your ideas are correct?

```

> ANSWER:

```{r}

```

```{exercise, name="Formulate a specific research question"}
Based on your preliminary visualizations and exploration of the date, formulate a more specific research question/hypothesis within this broad area of understanding the causes of flight delays.

```

> ANSWER:

```{r}

```


```{exercise, name="Share a visualization"}
Develop a single visualization to share with the class that tells a story about your more specific research question/hypothesis. Note: the story may very well be something along the lines of "we thought variable X would affect flight delays in way Y, but the evidence does not support that."

```

> ANSWER:

```{r}

```


