Skip to content

Commit

Permalink
Merge pull request #6 from RamiKrispin/data-refresh-03/22
Browse files Browse the repository at this point in the history
V0.1.2
  • Loading branch information
RamiKrispin committed Mar 16, 2023
2 parents f85b2e0 + a1dd149 commit 10dd11a
Show file tree
Hide file tree
Showing 107 changed files with 137,343 additions and 18,993 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
^vignettes/v2_analyzing_sfo.Rmd$
^CRAN-RELEASE$
^man/figures/sfo.png$
^CRAN-SUBMISSION$
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 0.1.2
Date: 2023-03-16 17:25:58 UTC
SHA: 7ad617e81329699deaa43ba4ec44f663bd67fdcb
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: sfo
Type: Package
Title: San Francisco International Airport Monthly Air Passengers
Version: 0.1.1
Version: 0.1.2
Authors@R: person(given = "Rami",
family ="Krispin",
email = "rami.krispin@gmail.com",
Expand All @@ -21,5 +21,5 @@ Suggests:
knitr,
rmarkdown,
tidyr (>= 1.0.0)
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
VignetteBuilder: knitr
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# sfo 0.1.2

* Updated the passengers and landing datasets - up to Dec 2022
* Updated the package documentation and examples

# sfo 0.1.1

* Updated the passengers data - up to Dec 2020 (including)
Expand Down
22 changes: 11 additions & 11 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
#' @format A data frame with 12 variables.
#' \describe{
#' \item{activity_period}{Activity year and month in YYYYMM format}
#' \item{operating_airline}{Airline name for the operator of aircraft}
#' \item{operating_airline}{Airline name for the aircraft operator}
#' \item{operating_airline_iata_code}{The International Air Transport Association (IATA) two-letter designation for the Operating Airline}
#' \item{published_airline}{Airline name that issues the ticket and books revenue for passenger activity}
#' \item{published_airline_iata_code}{The International Air Transport Association (IATA) two-letter designation for the Published Airline}
#' \item{geo_summary}{Designates whether the passenger activity in relation to SFO arrived from or departed to a location within the United States (“domestic”), or outside the United States (“international”) without stops}
#' \item{geo_region}{Provides a more detailed breakdown of the GEO Summary field to designate the region in the world where activity in relation to SFO arrived from or departed to without stops}
#' \item{geo_summary}{The flights’ classification by domestic for flights that arrived from or departed to a destination within the United States and international for destinations outside the United States}
#' \item{geo_region}{The flight origin/destination geographic region details}
#' \item{activity_type_code}{A description of the physical action a passenger took in relation to a flight, which includes boarding a flight (“enplanements”), getting off a flight (“deplanements”) and transiting to another location (“intransit”)}
#' \item{price_category_code}{A categorization of whether a Published Airline is a low-cost carrier or not a low-cost carrier}
#' \item{terminal}{The airport terminal designations at SFO where passenger activity took place}
#' \item{boarding_area}{The airport boarding area designations at SFO where passenger activity took place}
#' \item{terminal}{The airport’s terminal designations at SFO where passenger activity took place}
#' \item{boarding_area}{The airport’s boarding area designations at SFO where passenger activity took place}
#' \item{passenger_count}{The number of monthly passengers associated with the above attribute fields}
#'
#' }
Expand Down Expand Up @@ -45,17 +45,17 @@
#' @format A data frame with 14 variables.
#' \describe{
#' \item{activity_period}{Activity year and month in YYYYMM format}
#' \item{operating_airline}{Airline name for the operator of aircraft}
#' \item{operating_airline}{Airline name for the aircraft operator}
#' \item{operating_airline_iata_code}{The International Air Transport Association (IATA) two-letter designation for the Operating Airline}
#' \item{published_airline}{Airline name that issues the ticket and books revenue for passenger activity}
#' \item{published_airline_iata_code}{The International Air Transport Association (IATA) two-letter designation for the Published Airline}
#' \item{geo_summary}{Designates whether the passenger activity in relation to SFO arrived from or departed to a location within the United States (“domestic”), or outside the United States (“international”) without stops}
#' \item{geo_region}{Provides a more detailed breakdown of the GEO Summary field to designate the region in the world where activity in relation to SFO arrived from or departed to without stops}
#' \item{landing_aircraft_type}{A designation for three types of aircraft that landed at SFO, which includes passenger aircraft, cargo only aircraft (“freighters”) or combination aircraft (“combi”)}
#' \item{aircraft_body_type}{A designation that is independent from Landing Aircraft Type, which determines whether commercial aircraft landed at SFO is a wide body jet, narrow body jet, regional jet or a propeller operated aircraft}
#' \item{geo_summary}{The flights’ classification by domestic for flights that arrived from or departed to a destination within the United States and international for destinations outside the United States}
#' \item{geo_region}{ The flight origin/destination geographic region details}
#' \item{landing_aircraft_type}{A designation for three types of aircraft that landed at SFO, which includes passenger aircraft, cargo-only aircraft (“freighters”), or combination aircraft (“combi”)}
#' \item{aircraft_body_type}{A designation that is independent from Landing Aircraft Type, which determines whether commercial aircraft landed at SFO is a wide body-jet, narrow-body jet, regional-jet or a propeller operated aircraft}
#' \item{aircraft_manufacturer}{Manufacturer name for the aircraft that landed at SFO}
#' \item{aircraft_model}{Model designation of aircraft by the manufacturer}
#' \item{aircraft_version}{Variations of the Aircraft Model, also known as the “dash number”, designated by the manufacturer to segregate unique versions of the same model}
#' \item{aircraft_version}{ Variations of the Aircraft Model, also known as the “dash number”, designated by the manufacturer to segregate unique versions of the same model}
#' \item{landing_count}{The number of aircraft landings associated with General and Landings Statistics attribute fields}
#' \item{total_landed_weight}{The aircraft landed weight (in pounds) associated with General and Landings Statistics attribute fields}
#'
Expand Down
19 changes: 19 additions & 0 deletions R/dataviz.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@
#' @param cat_cols A vector of at least two categorical columns names
#' @param num_col A single numeric column name
#' @param title Optional, string to pass to plotly layout title function
#' @examples
#' data("sfo_passengers")
#'
#' library(dplyr)
#'
#' d <- sfo_passengers %>%
#' filter(activity_period >= 202201 & activity_period < 202301)
#'
#' head(d)
#'
#' d %>%
#' filter(operating_airline == "United Airlines") %>%
#' mutate(terminal = ifelse(terminal == "International", "international", terminal)) %>%
#' group_by(operating_airline,activity_type_code, geo_summary, geo_region, terminal) %>%
#' summarise(total = sum(passenger_count), .groups = "drop") %>%
#' sankey_ly(cat_cols = c("operating_airline", "terminal","geo_summary",
#' "geo_region", "activity_type_code"),
#' num_col = "total",
#' title = "Distribution of United Airlines Passengers at SFO During 2022")


sankey_ly <- function(x, cat_cols, num_col, title = NULL){
Expand Down
5 changes: 5 additions & 0 deletions R/global_variables.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
globalVariables(
c("activity_period",
"passenger_count",
"landing_count",
"total_landed_weight"))
36 changes: 17 additions & 19 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ orca(p, "man/figures/total.svg")

<!-- badges: start -->

[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/sfo)](https://cran.r-project.org/package=sfo) [![lifecycle](https://img.shields.io/badge/lifecycle-stable-green.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![GitHub commit](https://img.shields.io/github/last-commit/RamiKrispin/sfo)](https://github.com/RamiKrispin/sfo/commit/main)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/sfo)](https://cran.r-project.org/package=sfo) [![lifecycle](https://img.shields.io/badge/lifecycle-stable-green.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/license/mit/) [![GitHub commit](https://img.shields.io/github/last-commit/RamiKrispin/sfo)](https://github.com/RamiKrispin/sfo/commit/main)

<!-- badges: end -->

The **sfo** package provides summary statistics of the monthly passengers and landing in San Francisco International Airport (SFO) between 2005 and 2020.

The **sfo** package summarizes the monthly air passengers and landings at San Francisco International Airport (SFO) between 2005 and 2022.
Data source: San Francisco data portal - [DataSF API](https://datasf.org/opendata/)

<img src="man/figures/total.svg" width="90%"/>
Expand All @@ -69,13 +67,13 @@ devtools::install_github("RamiKrispin/sfo", ref = "main")
The **sfo** package provides the following two datasets:

* `sfo_passengers` - air traffic passengers statistics
* `sfo_stats` - air traffic landing statistics
* `sfo_stats` - air traffic landings statistics

More information about the datasets available on the following [vignette](https://ramikrispin.github.io/sfo/articles/v1_intro.html).
More information about the datasets is available in the following [vignette](https://ramikrispin.github.io/sfo/articles/v1_intro.html).

### Examples

The `sfo_passengers` dataset provides a monthly summary of the number of passengers in SFO airport by different categories (such as terminal, geo, type, etc.):
The `sfo_passengers` dataset provides monthly summary of the number of passengers in SFO airport by different categories (such as terminal, geo, type, etc.):

```{r }
library(sfo)
Expand All @@ -85,7 +83,7 @@ data("sfo_passengers")
head(sfo_passengers)
```

The `sfo_stats` dataset provides a monthly statistics on the air traffic landing at SFO airport:
The `sfo_stats` dataset provides monthly statistics on the air traffic landing at SFO airport:

```{r }
data("sfo_stats")
Expand All @@ -107,7 +105,7 @@ sfo_passengers %>%
```


The `sankey_ly` function enables us to plot the distribution of a numeric variable by multiple categorical variables. The following example shows the distribution of the total United Airlines passengers during 2019 by terminal, travel type (domestic and international), geo, and travel direction (deplaned, enplaned, and transit):
The `sankey_ly` function enables us to plot the distribution of a numeric variable by multiple categorical variables. The following example shows the distribution of the total United Airlines passengers during 2019 by a terminal, travel type (domestic and international), geo, and travel direction (deplaned, enplaned, and transit):

``` r
sfo_passengers %>%
Expand Down Expand Up @@ -140,11 +138,11 @@ orca(p, "man/figures/sankey.svg")

#### Total number of landing

The total number of landing in most recent month by `activity_type_code` and `aircraft_manufacturer`:
The total number of landings during the most recent month by `activity_type_code` and `aircraft_manufacturer`:

``` r
sfo_stats %>%
filter(activity_period == max(activity_period),
filter(activity_period == 202212,
aircraft_manufacturer != "") %>%
group_by(aircraft_manufacturer) %>%
summarise(total_landing = sum(landing_count),
Expand All @@ -153,13 +151,13 @@ sfo_stats %>%
plot_ly(labels = ~ aircraft_manufacturer,
values = ~ total_landing) %>%
add_pie(hole = 0.6) %>%
layout(title = "Landing Distribution by Aircraft Manufacturer during Sep 2020")
layout(title = "Landing Distribution by Aircraft Manufacturer during Dec 2022")
```


```{r, include=FALSE}
p <- sfo_stats %>%
filter(activity_period == max(activity_period),
filter(activity_period == 202212,
aircraft_manufacturer != "") %>%
group_by(aircraft_manufacturer) %>%
summarise(total_landing = sum(landing_count),
Expand All @@ -168,18 +166,18 @@ p <- sfo_stats %>%
plot_ly(labels = ~ aircraft_manufacturer,
values = ~ total_landing) %>%
add_pie(hole = 0.6) %>%
layout(title = "Landing Distribution by Aircraft Manufacturer During Sep 2020")
layout(title = "Landing Distribution by Aircraft Manufacturer During Dec 2022")
orca(p, "man/figures/manufacturer.svg")
```

<img src="man/figures/manufacturer.svg" width="100%"/>

The following Sankey plot demonstrate the distribution of number of landing in SFO by region and aircraft type, manufacturer, and body type during Sep 2020:
The following Sankey plot demonstrates the distribution of the number of landing in SFO by region and aircraft type, manufacturer, and body type during Dec 2022:

``` r
sfo_stats %>%
filter(activity_period == max(activity_period)) %>%
filter(activity_period == 202212) %>%
group_by(geo_summary, geo_region, landing_aircraft_type, aircraft_manufacturer, aircraft_body_type) %>%
summarise(total_landing = sum(landing_count),
groups = "drop") %>%
Expand All @@ -188,14 +186,14 @@ sfo_stats %>%
"aircraft_manufacturer",
"aircraft_body_type"),
num_col = "total_landing",
title = "Landing Summary by Geo Region and Aircraft Type During Sep 2020")
title = "Landing Summary by Geo Region and Aircraft Type During Dec 2022")

```


```{r, include=FALSE}
p <- sfo_stats %>%
filter(activity_period == max(activity_period)) %>%
filter(activity_period == 202212) %>%
group_by(geo_region, landing_aircraft_type, aircraft_manufacturer, aircraft_body_type) %>%
summarise(total_landing = sum(landing_count),
groups = "drop") %>%
Expand All @@ -204,7 +202,7 @@ p <- sfo_stats %>%
"aircraft_manufacturer",
"aircraft_body_type"),
num_col = "total_landing",
title = "Landing Summary by Geo Region and Aircraft Type During Sep 2020")
title = "Landing Summary by Geo Region and Aircraft Type During Dec 2022")
orca(p, "man/figures/landing_sankey.svg")
```
Expand Down
Loading

0 comments on commit 10dd11a

Please sign in to comment.