# Set working directory
setwd("~/Documents/Classes/Year 5/Fall 2019/Visual Analytics/Module 14 Final Proj")

# Include required packages
library(ggplot2)
library(readr)
library(plyr)
library(gganimate)
library(magick)
## Linking to ImageMagick 6.9.9.39
## Enabled features: cairo, fontconfig, freetype, lcms, pango, rsvg, webp
## Disabled features: fftw, ghostscript, x11
library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ tibble  2.1.3     ✔ dplyr   0.8.3
## ✔ tidyr   1.0.0     ✔ stringr 1.4.0
## ✔ purrr   0.3.3     ✔ forcats 0.4.0
## ── Conflicts ──────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::arrange()   masks plyr::arrange()
## ✖ purrr::compact()   masks plyr::compact()
## ✖ dplyr::count()     masks plyr::count()
## ✖ dplyr::failwith()  masks plyr::failwith()
## ✖ dplyr::filter()    masks stats::filter()
## ✖ dplyr::id()        masks plyr::id()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ dplyr::mutate()    masks plyr::mutate()
## ✖ dplyr::rename()    masks plyr::rename()
## ✖ dplyr::summarise() masks plyr::summarise()
## ✖ dplyr::summarize() masks plyr::summarize()
# Load Flight Stats dataset
flightstats <- read_csv("flightstats.csv")
## Parsed with column specification:
## cols(
##   date = col_date(format = ""),
##   rpm = col_double()
## )
summary(flightstats)
##       date                 rpm          
##  Min.   :2000-01-01   Min.   :47363631  
##  1st Qu.:2004-10-24   1st Qu.:63122461  
##  Median :2009-08-16   Median :67975907  
##  Mean   :2009-08-16   Mean   :67677741  
##  3rd Qu.:2014-06-08   3rd Qu.:71796897  
##  Max.   :2019-04-01   Max.   :88031480
head(flightstats)
## # A tibble: 6 x 2
##   date            rpm
##   <date>        <dbl>
## 1 2000-01-01 55616343
## 2 2000-04-01 58390608
## 3 2000-07-01 58522145
## 4 2000-10-01 57910602
## 5 2001-01-01 58095672
## 6 2001-04-01 58381701
#Create Base Plot
ggplot(flightstats) +
  geom_line(aes(x = date, y = rpm))

#Update labels
ggplot(flightstats) +
  geom_line(aes(x = date, y = rpm)) +
  labs(title = "Revenue Passenger Miles", y = " Revenue Passenger Miles (Millions)", x = "") 

#Add line color and theme
ggplot(flightstats) +
  geom_line(aes(x = date, y = rpm), color = "red") +
  labs(title = "Revenue Passenger Miles", y = " Revenue Passenger Miles (Millions)", x = "") +
  theme_light() +
  theme(plot.title = element_text(hjust = 0.5))