View source: R/get_route_timetable.R
| get_route_timetable | R Documentation |
Returns the timetable of the given routes on the given dates: one row for each stop time of their trips on each date on which the trip runs.
get_route_timetable(gtfs, route_id = NULL, date = NULL)
gtfs |
A GTFS object, as created by |
route_id |
A character vector including the |
date |
A |
A data.table with the column date (of class Date), followed by
all the columns of trips and all the columns of stop_times (trip_id
appears only once). It is sorted by date and route_id, and then the
trips of each route are sorted by their first departure time (and
trip_id), each with its stop times sorted by stop_sequence. If the
given routes have no trips on the given dates, an empty table with the
same columns is returned, without a warning.
A trip runs on a date if its service is active on it, as in
get_active_services(), so dates outside the period covered by the GTFS
object are skipped. Trips listed in stop_times but not in trips are not
included. Departure times are sorted as times, not as strings, and trips
without any departure time come last in their route. Duplicated rows in
trips and stop_times are kept.
Without calendar and calendar_dates tables, no trip runs, and an empty
table is returned. Columns other than trip_id present in both trips and
stop_times (not defined by the GTFS reference) appear twice, the one from
stop_times prefixed with i., and the ones from trips are used to sort
the timetable.
date is the service date: stop times past 24:00:00 happen on the
following calendar day.
The frequencies table is not used: frequency-based trips appear with the
times of their template trips, as listed in stop_times. To include all
their departures, convert them with frequencies_to_stop_times() first.
get_stop_timetable(), get_active_services(), get_dates()
data_path <- system.file("extdata/ber_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
timetable <- get_route_timetable(gtfs, "1922_3", "20210104")
head(timetable)
# several routes and dates, also as Date objects
timetable <- get_route_timetable(
gtfs,
route_id = c("1922_3", "1921_3"),
date = as.Date(c("2021-01-04", "2021-01-09"))
)
table(timetable$date, timetable$route_id)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.