get_headways | R Documentation |
The 'get_headways' function calculates headways within a 'wizardgtfs' object using different methods. Depending on the selected 'method', it can provide average headways by route, by trip, by hour, or detailed stop-level headways.
get_headways(gtfs, method = "by.route")
gtfs |
A GTFS object, ideally of class 'wizardgtfs'. If not, it will be converted. |
method |
A character string specifying the calculation method. Options include:
|
This function calls specific sub-functions based on the selected method:
- "by.route": Calculates the average headway for each route based on the first stop time per trip.
- "by.hour": Calculates the hourly headway for each route, grouping trips by hour.
- "by.trip": Calculates headways for each trip, considering only the first stop time.
- "by.stop": Calculates headways for each stop.
- "by.shape": Calculates headways for each shape.
- "detailed": Provides headway calculations for each consecutive stop within each trip.
If an invalid 'method' is specified, the function defaults to '"by.route"' and provides a warning.
A data frame containing service headways based on the specified method:
Returns a data frame with columns: 'route_id', 'valid_trips', 'average_headway', 'service_pattern', and 'pattern_frequency'.
Returns a data frame with columns: 'hour', 'valid_trips', 'average_headway', 'service_pattern', and 'pattern_frequency'.
Returns a data frame with columns: 'route_id', 'trip_id', 'headway', 'service_pattern', and 'pattern_frequency'.
Returns a data frame with columns: 'stop_id', 'direction_id', 'valid_trips', 'headway', 'service_pattern', and 'pattern_frequency'.
Returns a data frame with columns: 'shape_id', 'direction_id', 'valid_trips', 'headway', 'service_pattern', and 'pattern_frequency'.
Returns a data frame with columns: 'route_id', 'trip_id', 'stop_id', 'hour', 'headway', 'service_pattern', and 'pattern_frequency'.
[GTFSwizard::as_wizardgtfs()], [GTFSwizard::get_servicepattern()]
# Calculate average route headways
headways_by_route <- get_headways(gtfs = for_rail_gtfs, method = "by.route")
# Calculate hourly headways
headways_by_hour <- get_headways(gtfs = for_rail_gtfs, method = "by.hour")
# Calculate headways for each trip
headways_by_trip <- get_headways(gtfs = for_rail_gtfs, method = "by.trip")
# Calculate headways for each stop
headways_by_stop <- get_headways(gtfs = for_rail_gtfs, method = "by.stop")
# Calculate headways for each shape
headways_by_shape <- get_headways(gtfs = for_rail_gtfs, method = "by.shape")
# Calculate detailed stop-level headways
detailed_headways <- get_headways(gtfs = for_rail_gtfs, method = "detailed")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.