library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
library(zoo)
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
hw5data <- read.csv("https://raw.githubusercontent.com/mkollontai/DATA607/master/HW5/HW5data.csv", header=TRUE, sep=",")

hw5data_2 <- hw5data %>% 
  na.omit %>% 
  gather("City","Instances", 3:7)
hw5data_2$X[hw5data_2$X == ""] <- NA
hw5data_2 <- na.locf(hw5data_2)
hw5data_3 <- spread(hw5data_2,X.1,Instances)
hw5data_3 %>%
  group_by(X) %>%
  summarize(mean(delayed))
## # A tibble: 2 x 2
##   X       `mean(delayed)`
##   <fct>             <dbl>
## 1 Alaska             100.
## 2 AM West            157.

On average AM west was delayed by nearly an hour more than Alaska airlines (57.2 minutes more).