View source: R/get_route_speed.R
| get_route_speed | R Documentation |
Returns summary statistics of the average speeds of the trips of each
specified route_id.
get_route_speed(
gtfs,
route_id = NULL,
method = "shapes",
unit = "km/h",
from = NULL,
to = NULL
)
gtfs |
A GTFS object, as created by |
route_id |
A character vector including the |
method |
A string, either |
unit |
A string representing the unit in which the speeds are desired.
One of |
from |
A string, in the "HH:MM:SS" format. Only trips that depart from
their first stop at or after |
to |
A string, in the "HH:MM:SS" format. Only trips that depart from
their first stop at or before |
A data.table with the route_id and the minimum (min_speed),
mean (mean_speed), median (median_speed), maximum (max_speed) and
standard deviation (sd_speed) of the speeds of its trips, ordered by
route_id.
The speed of each trip is calculated with get_trip_speed() (with
by = "trip"), whose details also apply here. Each trip is linked to its
route by the trips table. mean_speed is the unweighted mean of the trip
speeds, not the total length of the trips divided by their total duration.
Trips listed in frequencies count once, regardless of their headways.
Trips with NA speeds are ignored. Routes whose trips all have NA speeds
get NA statistics, and sd_speed is NA for routes with a single trip
with a known speed. Routes without any trip in stop_times (or, if from
or to is given, without any trip departing within the time of day) are
not returned.
get_trip_speed(), set_route_speed(), set_trip_speed()
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
route_speed <- get_route_speed(gtfs)
head(route_speed)
route_ids <- c("CPTM L07", "2002-10")
route_speed <- get_route_speed(gtfs, route_ids)
route_speed
route_speed <- get_route_speed(gtfs, route_ids, method = "euclidean")
route_speed
route_speed <- get_route_speed(gtfs, route_ids, unit = "m/s")
route_speed
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.