--- title: "Stat. 450 Quiz preparation" output: word_document: default pdf_document: default html_notebook: default --- **Stat. 450:** Quiz preparation These question is related to the homework problem 5.6.7 Exercise 1. For the flights data, in the nycflights13 package, answer the following questions: ```{r message=FALSE} library(nycflights13) library(tidyverse) ``` 1. How many flights arrived on time (which includes the flights that arrived early)? To answer this question we will look at the arr_delay to look at the flights that arrived on time. **Answer:** 194,342 ```{r} flights %>% select(arr_delay) %>% filter(arr_delay <= 0) %>% summarize( n=n() ) ``` 2. What proportion of flights arrived on time? To answer this question we will look at the arr_delay to look at the flights that arrived on time. **Answer:** Approximately 60%. ```{r} flights %>% select(arr_delay) %>% summarize( arr_delay_mean = mean(arr_delay <= 0, na.rm = TRUE) ) ``` 3. How many United flights arrived 30 or more minutes late? **Answer:** The number of UA flights that arrived 30 or more minutes late was 8131. ```{r} flights %>% filter( carrier == "UA") %>% count(arr_delay >= 30) ``` 4. Which airline has the best on-time performance? **Answer:** AS ```{r} flights %>% select(arr_delay, carrier) %>% group_by(carrier) %>% summarize( n=n(), arr_delay_mean=mean(arr_delay <= 0, na.rm = TRUE) ) %>% arrange(desc(arr_delay_mean)) ``` 5. Which airline has the worst on-time performance? **Answer:** FL ```{r} flights %>% select(arr_delay, carrier) %>% group_by(carrier) %>% summarize( n=n(), arr_delay_mean=mean(arr_delay <= 0, na.rm = TRUE) ) %>% arrange(arr_delay_mean) ```