February 2026: The package has become obsolete and will no longer be
updated. To obtain NTD data, you should use the excellent
socratadata package to
access the data.transportation.gov API.
# old way to obtain data
library(ntdr)
get_ntd()
# new way to obtain data
library(socratadata)
soc_read("https://data.transportation.gov/Public-Transit/Complete-Monthly-Ridership-with-Adjustments-and-Es/8bui-9xvu/about_data")
January 2025: Unfortunately, the package no longer works. Download requests from the package to the US Department of Transportation’s servers are getting blocked.
The ntdr package provides a convenient interface to retrieve monthly
data from the National Transit Database (NTD). Without this package,
getting NTD data involves going to the NTD website and downloading and
processing a complex Excel workbook.
The NTD data returned by this package has many quirks and subtleties. Please use it with care and report any issues.
To learn more about the package, visit the package website: https://vgxhc.github.io/ntdr/.
The package currently does not pass CRAN checks and you need to install the development version.
# Install the latest development version from GitHub:
remotes::install_github("vgXhc/ntdr")
Basic usage:
library(ntdr)
options(ntdr.cache = TRUE)
ntd_madison <- get_ntd(
data_type = "adjusted",
ntd_variable = "UPT",
agency = "City of Madison",
modes = "MB"
)
head(ntd_madison)
#> # A tibble: 6 × 13
#> ntd_id_5 ntd_id_4 agency active reporter_type uace uza_name modes tos
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 50005 5005 City of Mad… Active Full Reporter 53200 Madison… MB DO
#> 2 50005 5005 City of Mad… Active Full Reporter 53200 Madison… MB DO
#> 3 50005 5005 City of Mad… Active Full Reporter 53200 Madison… MB DO
#> 4 50005 5005 City of Mad… Active Full Reporter 53200 Madison… MB DO
#> 5 50005 5005 City of Mad… Active Full Reporter 53200 Madison… MB DO
#> 6 50005 5005 City of Mad… Active Full Reporter 53200 Madison… MB DO
#> # ℹ 4 more variables: modes_simplified <chr>, month <date>, value <dbl>,
#> # ntd_variable <chr>