---
output: pdf_document
---

Airline Delays in the First Course (part 3: accessing the data from Flagstaff)
========================================================
Nicholas Horton, nhorton@amherst.edu, July 15, 2014
------------------------------------------------------

#### Accessing the data

```{r,eval=TRUE,echo=TRUE}
require(RMySQL)
con = dbConnect(MySQL(), user="mth292", host="rucker.smith.edu", password="XX", dbname="airlines")
```

```{r, tidy=TRUE}
ds = dbGetQuery(con, "SELECT DayofMonth, Month, Year, Origin, Dest, 
                UniqueCarrier, TailNum, CRSDepTime, ArrDelay, Cancelled
    FROM ontime WHERE Origin='FLG' AND Year > 2010 AND Month = 7")
# returns a data frame with approximately 500 observations
ds = transform(ds, date =
   as.Date(paste(Year, "-", Month, "-", DayofMonth, sep="")))
ds = transform(ds, weekday = weekdays(date))
ds = ds[order(ds$date),]
save(ds, file="ICOTS-FLG.rda")
```
