Skip to content

Commit

Permalink
Implement changes from PR #53
Browse files Browse the repository at this point in the history
  • Loading branch information
jabenninghoff committed Mar 17, 2024
1 parent 97c0aed commit 9e99a5f
Show file tree
Hide file tree
Showing 15 changed files with 26,622 additions and 26,527 deletions.
2 changes: 1 addition & 1 deletion R/airlines.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Look up airline names from their carrier codes.
#'
#' @source <https://www.transtats.bts.gov/DL_SelectFields.asp?Table_ID=236>
#' @source <https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FGJ&QO_fu146_anzr=b0-gvzr>
#' @format Data frame with columns
#' \describe{
#' \item{carrier}{Two letter abbreviation.}
Expand Down
2 changes: 1 addition & 1 deletion R/flights.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' 2013.
#'
#' @source RITA, Bureau of transportation statistics,
#' <https://www.transtats.bts.gov/DL_SelectFields.asp?Table_ID=236>
#' <https://www.transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FGJ&QO_fu146_anzr=b0-gvzr>
#' @format Data frame with columns
#' \describe{
#' \item{year, month, day}{Date of departure.}
Expand Down
2 changes: 1 addition & 1 deletion data-raw/airlines.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library(dplyr)
library(readr)

raw <- read_csv("https://www.transtats.bts.gov/Download_Lookup.asp?Lookup=L_UNIQUE_CARRIERS")
raw <- read_csv("https://www.transtats.bts.gov/Download_Lookup.asp?Y11x72=Y_haVdhR_PNeeVRef")

load("data/flights.rda")

Expand Down
2 changes: 1 addition & 1 deletion data-raw/airlines.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ AA,American Airlines Inc.
AS,Alaska Airlines Inc.
B6,JetBlue Airways
DL,Delta Air Lines Inc.
EV,ExpressJet Airlines Inc.
EV,ExpressJet Airlines LLC d/b/a aha!
F9,Frontier Airlines Inc.
FL,AirTran Airways Corporation
HA,Hawaiian Airlines Inc.
Expand Down
2 changes: 1 addition & 1 deletion data-raw/airports.csv
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ faa,name,lat,lon,alt,tz,dst,tzone
19A,Jackson County Airport,34.1758638,-83.5615972,951,-5,U,America/New_York
1A3,Martin Campbell Field Airport,35.0158056,-84.3468333,1789,-5,A,America/New_York
1B9,Mansfield Municipal,42.0001331,-71.1967714,122,-5,A,America/New_York
1C9,Frazier Lake Airpark,54.013333333333335,-124.76833333333333,152,-8,A,America/Vancouver
1C9,Frazier Lake Airpark,54.013333333333335,-124.76833333333332,152,-8,A,America/Vancouver
1CS,Clow International Airport,41.6959744,-88.1292306,670,-6,U,America/Chicago
1G3,Kent State Airport,41.1513889,-81.4151111,1134,-5,A,America/New_York
1G4,Grand Canyon West Airport,35.899904,-113.815674,4813,-7,A,America/Phoenix
Expand Down
2,931 changes: 1,470 additions & 1,461 deletions data-raw/airports.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions data-raw/flights.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ library(readr)

flight_url <- function(year = 2013, month) {
base_url <- "https://www.transtats.bts.gov/PREZIP/"
sprintf(paste0(base_url, "On_Time_On_Time_Performance_%d_%d.zip"), year, month)
sprintf(paste0(base_url, "On_Time_Reporting_Carrier_On_Time_Performance_1987_present_%d_%d.zip"), year, month)
}

download_month <- function(year = 2013, month) {
Expand Down Expand Up @@ -35,15 +35,14 @@ get_nyc <- function(path) {
ArrTime = col_integer(),
CRSDepTime = col_integer(),
CRSArrTime = col_integer(),
Carrier = col_character(),
UniqueCarrier = col_character()
Reporting_Airline = col_character()
)
read_csv(path, col_types = col_types) %>%
select(
year = Year, month = Month, day = DayofMonth,
dep_time = DepTime, sched_dep_time = CRSDepTime, dep_delay = DepDelay,
arr_time = ArrTime, sched_arr_time = CRSArrTime, arr_delay = ArrDelay,
carrier = Carrier, flight = FlightNum, tailnum = TailNum,
carrier = Reporting_Airline, flight = Flight_Number_Reporting_Airline, tailnum = Tail_Number,
origin = Origin, dest = Dest,
air_time = AirTime, distance = Distance
) %>%
Expand Down
17 changes: 10 additions & 7 deletions data-raw/planes.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ library(readr)

# Update URL from
# http://www.faa.gov/licenses_certificates/aircraft_certification/aircraft_registry/releasable_aircraft_download/
src <- "http://registry.faa.gov/database/AR062014.zip"
src <- "https://registry.faa.gov/database/yearly/ReleasableAircraft.2013.zip"
lcl <- "data-raw/planes"

# TODO: fix download - workaround is to download and extract src zip manually
if (!file.exists(lcl)) {
tmp <- tempfile(fileext = ".zip")
download.file(src, tmp)
Expand All @@ -15,20 +16,22 @@ if (!file.exists(lcl)) {
}

master <- read.csv("data-raw/planes/MASTER.txt", stringsAsFactors = FALSE, strip.white = TRUE)
names(master) <- tolower(names(master))

keep <- master %>%
tbl_df() %>%
select(nnum = n.number, code = mfr.mdl.code, year = year.mfr)
as_tibble() %>%
select("nnum" = 1, "code" = 3, "year" = 5)

ref <- read.csv("data-raw/planes//ACFTREF.txt",
ref <- read.csv("data-raw/planes/AcftRef.txt",
stringsAsFactors = FALSE,
strip.white = TRUE
)
names(ref) <- tolower(names(ref))
names(ref) <-
c("mfr", "model", "type.acft", "type.eng", "ac.category",
"amat.tc.built", "no.eng", "no.seats", "ac.weight", "speed", "code",
"kit.code", "extra")

ref <- ref %>%
tbl_df() %>%
as_tibble() %>%
select(code, mfr, model, type.acft, type.eng, no.eng, no.seats, speed)

# Combine together
Expand Down
84 changes: 61 additions & 23 deletions data-raw/planes.csv

Large diffs are not rendered by default.

50,100 changes: 25,073 additions & 25,027 deletions data-raw/weather.csv

Large diffs are not rendered by default.

Binary file added data/airlines.rda
Binary file not shown.
Binary file added data/airports.rda
Binary file not shown.
Binary file added data/flights.rda
Binary file not shown.
Binary file added data/planes.rda
Binary file not shown.
Binary file added data/weather.rda
Binary file not shown.

0 comments on commit 9e99a5f

Please sign in to comment.