This function returns a new tidygtfs object with only the information
relevant to your desired routes and directions. All fields included in the
input gtfs will be filtered. See Details for more information about
required files and fields
Details
The following files and fields are required for this function:
routes: withroute_idandagency_idagency: withagency_idtrips: withroute_id,direction_id,shape_id,service_id, andtrip_idstop_times: withstop_idandtrip_id
The following files are optional. If they are included, the must include the listed fields:
stops: withstop_idshapes: withshape_idcalendar: withservice_idcalendar_dates: withservice_idtransfers: withtrip_idandstop_idfrequencies: withtrip_idfare_rules: withroute_idfeed_info
For these optional files, the function will detect whether they are present.
If so, they will be filtered; if not, they will be left NULL in the new
GTFS. If any required file or field is missing, an error will be thrown
describing what is missing.
Examples
# Set my parameters
my_route <- "C53"
my_dir <- 0
# Filter WMATA GTFS
c53_gtfs <- filter_by_route(gtfs = wmata_gtfs,
route_ids = my_route,
dir_id = 0)
summary(c53_gtfs)
#> tidygtfs object
#> files agency, routes, stop_times, trips, shapes, calendar, calendar_dates, stops
#> agency WMATA
#> service from 2025-12-14 to 2026-06-13
#> uses stop_times (no frequencies)
#> # routes 1
#> # trips 952
#> # stop_ids 57
#> # stop_names 57
#> # shapes 2