Learn R Programming

tidytransit (version 0.7.2)

read_gtfs: Get and validate dataframes of General Transit Feed Specification (GTFS) data.

Description

This function reads GTFS text files from a local or remote zip file. It also validates the files against the GTFS specification by file, requirement status, and column name.

Usage

read_gtfs(path, quiet = TRUE)

Arguments

path

Character. URL link to zip file OR path to local zip file.

quiet

Boolean. Whether to see file download progress and files extract. FALSE by default.

Value

A GTFS object. That is, a list of dataframes of GTFS data.

Details

The data are returned as a list of dataframes and a validation object, which contains details on whether all required files were found, and which required and optional columns are present. #'

Examples

Run this code
# NOT RUN {
library(dplyr)
u1 <- "https://github.com/r-transit/tidytransit/raw/master/inst/extdata/sample-feed-fixed.zip"
sample_gtfs <- read_gtfs(u1)
attach(sample_gtfs)
#list routes by the number of stops they have
routes %>% inner_join(trips, by="route_id") %>%
  inner_join(stop_times) %>%
    inner_join(stops, by="stop_id") %>%
      group_by(route_long_name) %>%
        summarise(stop_count=n_distinct(stop_id)) %>%
          arrange(desc(stop_count))
# }

Run the code above in your browser using DataLab