introduction

2019-02-03

Travis-CI Build Status CRAN status

trread makes it easy to work with transit data by simplifying General Transit Feed Specification data (the standard format for storing transit data) into dataframes. Use it to calculate transit frequencies, and validate transit feeds.

trread is a fork of gtfsr, published to CRAN, with frequency calculation functions, and without GTFS-specific interactive cartography features.

Installation

This package requires a working installation of sf.

install.packages('trread')

# For the development version from Github:
# install.packages("devtools")
devtools::install_github("r-transit/trread")

Usage

Read GTFS data

## Calculating route and stop headways.

Headways by Route

View the headways along routes as a dataframe. routes_frequency_df is added to the list of gtfs dataframes read in by read_gtfs.

Use the GTFS Table Relationships diagram below to join these data to relevant data, for example, the more detailed route names on the routes_df.

## # A tibble: 6 x 5
##   route_id median_headways mean_headways st_dev_headways stop_count
##   <chr>              <int>         <int>           <dbl>      <int>
## 1 1                      5             5            0.15         76
## 2 2                      7            51          135.          120
## 3 3                      8             8            0.08         68
## 4 4                      6           115          205.           77
## 5 5                      9           110          271.          102
## 6 5X                    48            48            0            29
route_id median_headways mean_headways st_dev_headways stop_count
GS 4 4 0.01 4
L 4 4 0.13 48
1 5 5 0.14 76
7 5 5 0.29 44
6 6 7 2.84 76
E 6 23 53.01 48

Headways by Stop

View the headways at stops. stops_frequency_df is added to the list of gtfs dataframes read in by read_gtfs.

## # A tibble: 6 x 6
##   route_id direction_id stop_id service_id               departures headway
##   <chr>           <int> <chr>   <chr>                         <int>   <dbl>
## 1 1                   0 101N    ASP18GEN-1087-Weekday-00        177    5.42
## 2 1                   0 103N    ASP18GEN-1087-Weekday-00        177    5.42
## 3 1                   0 104N    ASP18GEN-1087-Weekday-00        177    5.42
## 4 1                   0 106N    ASP18GEN-1087-Weekday-00        178    5.39
## 5 1                   0 107N    ASP18GEN-1087-Weekday-00        183    5.25
## 6 1                   0 108N    ASP18GEN-1087-Weekday-00        183    5.25
## # A tibble: 6 x 4
## # Groups:   direction_id, stop_id [6]
##   direction_id stop_id stop_name             headway
##          <int> <chr>   <chr>                   <dbl>
## 1            0 902N    Times Sq - 42 St         3.60
## 2            1 901S    Grand Central - 42 St    3.60
## 3            1 902S    Times Sq - 42 St         3.60
## 4            0 901N    Grand Central - 42 St    3.61
## 5            0 702N    Mets - Willets Point     3.72
## 6            0 707N    Junction Blvd            3.72