View source: R/get_dwell_time.R
| get_dwell_time | R Documentation |
Returns the dwell time of each specified trip_id at each specified
stop_id, i.e. the time the vehicle stays at the stop, as specified in the
stop_times table.
get_dwell_time(
gtfs,
trip_id = NULL,
stop_id = NULL,
unit = "s",
from = NULL,
to = NULL
)
gtfs |
A GTFS object, as created by |
trip_id |
A character vector including the |
stop_id |
A character vector including the |
unit |
A string representing the time unit in which the dwell times
are desired. One of |
from |
A string, in the "HH:MM:SS" format. Only visits whose arrival
time is at or after |
to |
A string, in the "HH:MM:SS" format. Only visits whose arrival time
is at or before |
A data.table with the columns trip_id, stop_id,
stop_sequence and dwell_time, with one row per visit of a specified
trip to a specified stop (within the time of day, if from or to is
given), ordered by trip_id and stop_sequence.
dwell_time is numeric, in the given unit, and NA where a time is
blank.
The dwell time of a visit is its departure_time minus its arrival_time
in stop_times. When both trip_id and stop_id are given, the visits of
every specified trip to every specified stop are returned (not of pairs
formed by their elements). The first and last stops of each trip are
included. For trips listed in frequencies, one dwell time is returned per
visit of the template, not per departure.
Blank times (NA dwell times) can be filled beforehand with
interpolate_stop_times(). Negative dwell times (departure earlier than
arrival) are returned as they are.
from and to are compared with the arrival_time of each visit as
written in stop_times (template times, for trips listed in
frequencies), so use times past "24:00:00" for arrivals after midnight.
Visits with a blank arrival time are never included when from or to is
given.
stop_ids are matched against the stop_ids in stop_times, which are
never stations: to get the dwell times at a station, pass its children that
appear in stop_times (see get_children_stops()). Existing _secs
columns in stop_times are not used; times are read from the time strings.
set_dwell_time(), set_min_dwell_time()
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
dwell_times <- get_dwell_time(gtfs)
head(dwell_times)
# use the trip_id and stop_id arguments to control which trips and stops
# are analyzed
get_dwell_time(gtfs, trip_id = "CPTM L07-0")
get_dwell_time(gtfs, stop_id = "18960")
get_dwell_time(
gtfs,
trip_id = c("CPTM L08-0", "CPTM L09-0"),
stop_id = "18960"
)
# blank times result in NA dwell times. use the unit argument to control in
# which unit the dwell times are calculated
ggl_path <- system.file("extdata/ggl_gtfs.zip", package = "gtfstools")
ggl_gtfs <- read_gtfs(ggl_path)
get_dwell_time(ggl_gtfs, trip_id = "AWE1", unit = "min")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.