get_1stdeparture {GTFSwizard} | R Documentation |
Get First Departure Times for GTFS Trips
Description
Extracts the first departure time for each trip in a 'wizardgtfs' object, along with the associated 'route_id', and 'stop_id' where the first departure occurs.
Usage
get_1stdeparture(gtfs)
Arguments
gtfs |
A GTFS object. If not of class 'wizardgtfs', it will be converted internally using 'as_wizardgtfs()'. This may increase computation time. |
Details
This function identifies the first departure time for each trip in the GTFS dataset. It uses the 'stop_times' table to find the earliest 'departure_time' for each 'trip_id' and joins this information with the 'trips' table to include the corresponding 'route_id'. The result is a tidy tibble suitable for further analysis or visualization.
If the input GTFS object is not of the 'wizardgtfs' class, the function converts it using 'as_wizardgtfs()'. A message is displayed to inform the user about the conversion.
Value
A tibble with the following columns:
- route_id
ID of the route associated with the trip.
- trip_id
ID of the trip.
- departure_time
Time of the first departure for the trip, as a character string in "HH:MM:SS" format.
- stop_id
ID of the stop where the first departure occurs.
See Also
[GTFSwizard::as_wizardgtfs()]
Examples
# Load GTFS data
gtfs <- for_rail_gtfs
# Get the first departures
first_departures <- get_1stdeparture(gtfs)
head(first_departures)