get_speeds | R Documentation |
'get_speeds' calculates the average speed of trips and routes within a 'wizardgtfs' object. It uses distance and duration to provide speed outputs based on the specified 'method'.
get_speeds(gtfs, method = "by.route", trips = "all")
gtfs |
A GTFS object, ideally of class 'wizardgtfs'. If the 'shapes' table is missing, it will be created automatically using 'get_shapes()'. |
method |
A character string specifying the calculation method. Options include:
|
trips |
A character vector of trip IDs to consider. When set to 'all', includes all trips. |
- This function calls specific sub-functions based on the selected 'method':
Calculates average speed across each route.
Calculates average speed across each trip.
Calculates speeds between consecutive stops within each trip.
- If an invalid 'method' is specified, the function defaults to '"by.route"' and provides a warning.
A data frame containing speed calculations, depending on the specified method:
Returns a data frame with columns: 'route_id', 'trips', 'average.speed', 'service_pattern', and 'pattern_frequency'.
Returns a data frame with columns: 'route_id', 'trip_id', 'average.speed', 'service_pattern', and 'pattern_frequency'.
Returns a data frame with columns: 'route_id', 'trip_id', 'hour', 'from_stop_id', 'to_stop_id', 'speed', 'service_pattern', and 'pattern_frequency'.
[GTFSwizard::get_distances()], [GTFSwizard::get_durations()], [GTFSwizard::get_shapes()]
# Calculate average route speeds
speeds_by_route <- get_speeds(gtfs = for_rail_gtfs, method = "by.route", trips = 'all')
# Calculate trip speeds
speeds_by_trip <- get_speeds(gtfs = for_rail_gtfs, method = "by.trip", trips = 'all')
# Calculate detailed speeds between stops
detailed_speeds <- get_speeds(gtfs = for_rail_gtfs, method = "detailed", trips = 'all')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.