library(ggvis)
## Warning: package 'ggvis' was built under R version 3.4.2
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.2
## 
## 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
flights <- read.csv("domestic_flights_jan_2016.csv", header = TRUE, stringsAsFactors = FALSE)
flights$FlightDate <- as.Date(flights$FlightDate, format = "%m/%d/%Y")
flights<- flights%>% mutate (new_CRSDepTime = paste(FlightDate, sprintf("%04d", CRSDepTime)))
flights<- flights %>% mutate(new_CRSArrTime = paste(FlightDate, sprintf("%04d", CRSArrTime)))
flights$new_CRSDepTime<- as.POSIXct(flights$new_CRSDepTime, format="%Y-%m-%d %H%M")
flights<- flights%>% filter(Cancelled  ==0) %>% mutate(new_DepTime = paste (FlightDate, sprintf("%04d", DepTime)), new_WheelsOff = paste(FlightDate, sprintf("%04d", WheelsOff)), new_WheelsOn = paste(FlightDate, sprintf("%04d", WheelsOn)), new_ArrTime = paste(FlightDate, sprintf("%04d", ArrTime)))
flights$new_DepTime<- as.POSIXct(flights$new_DepTime, format="%Y-%m-%d %H%M")
flights$new_WheelsOff<- as.POSIXct(flights$new_WheelsOff, format="%Y-%m-%d %H%M")
flights$new_WheelsOn<- as.POSIXct(flights$new_WheelsOn, format="%Y-%m-%d %H%M")
flights$new_ArrTime<- as.POSIXct(flights$new_ArrTime, format="%Y-%m-%d %H%M")
flights<- flights%>%filter(Cancelled ==0)%>% mutate (DepDelay = as.integer(difftime(new_DepTime, new_CRSDepTime, units = "mins")))
flights<- flights%>% filter(Cancelled==0) %>% mutate (TaxiOut = as.integer(difftime(new_WheelsOff, new_DepTime, units = "mins")))
flights<- flights%>% filter(Cancelled==0) %>% mutate (TaxiIn = as.integer(difftime(new_ArrTime, new_WheelsOn, units = "mins")))
flights<- flights%>% filter(Cancelled==0) %>% mutate (ArrDelay = as.integer(difftime(new_ArrTime, new_CRSArrTime, units = "mins")))
flights<- flights%>%filter(Cancelled==0)%>% mutate(DepDelayMins = ifelse(DepDelay<0,0,DepDelay))
flights<- flights%>%filter(Cancelled==0)%>% mutate(ArrDelayMins = ifelse(ArrDelay<0,0,ArrDelay))
flights<- flights%>%filter(Cancelled==0)%>% mutate(DepDelay15 = ifelse(DepDelay>15,1,0))
flights<- flights%>%filter(Cancelled==0)%>% mutate(ArrDelay15 = ifelse(ArrDelay>15,1,0))

Airports with most delayed arrivals

The data suggests that if you are waiting for someone to arrive in Atlanta, that you may want to stop at Jersey Mike’s in the airport and enjoy a delicious sub with their famous juice sauce. If you are waiting in Las Vegas, Houston, or Orlando, there is a high chance of delay than most other locations.

Airports with most prompt arrivals

The data suggests that if you are waiting for the Red Sox to return from a (hopefully) successful playoff road trip that they should be right on time as Boston stands out as one of the best locations regarding promptness.

Aiports with most delayed departures

Dallas (Fort Worth) and Minneapolis (Saint Paul) are the two locations that stand out in regards to departure delays. Both locations are central travel hubs in the United States.

Airports with the least delayed departures

Atlanta stands out as seemingly the best airport in regards to departing on time. They were able ensure that the Atlanta Falcons made it to SuperBowl 51, only to take a 28-3 lead and somehow manage to still lose the game.