View source: R/get_stop_timetable.R
| get_stop_timetable | R Documentation |
Returns the timetable of the given stops on the given dates: one row for each stop time at these stops on each date on which its trip runs.
get_stop_timetable(gtfs, stop_id = NULL, date = NULL)
gtfs |
A GTFS object, as created by |
stop_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, stop_id, departure time and
trip_id. If no trip stops at the given stops 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 stop
times with an empty departure_time come last at each stop. 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.
Only the exact given stops are included: to include the stops of a station,
pass them with get_children_stops(). 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_route_timetable(), get_active_services(), get_dates()
data_path <- system.file("extdata/ber_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
timetable <- get_stop_timetable(gtfs, "100000720101", "20210104")
head(timetable)
# several dates, also as Date objects
timetable <- get_stop_timetable(
gtfs,
stop_id = "100000720101",
date = as.Date(c("2021-01-04", "2021-01-09"))
)
table(timetable$date)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.