View source: R/set_min_dwell_time.R
| set_min_dwell_time | R Documentation |
Raises the dwell time of each specified trip_id at each specified
stop_id to at least min_dwell_time, i.e. makes vehicles stay at least
that long at the stops, by delaying the departure_time at these stops in
stop_times and shifting the later times of the trips accordingly.
set_min_dwell_time(
gtfs,
min_dwell_time,
unit = "s",
trip_id = NULL,
stop_id = NULL,
from = NULL,
to = NULL,
route_type = NULL,
by_reference = FALSE
)
gtfs |
A GTFS object, as created by |
min_dwell_time |
A non-negative number, the minimum dwell time, in
|
unit |
A string representing the time unit in which |
trip_id |
A character vector including the |
stop_id |
A character vector including the |
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 |
route_type |
An integer vector of |
by_reference |
Whether to update |
If by_reference is set to FALSE, returns a GTFS object with the
time columns of its stop_times adjusted. Else, returns a GTFS object
invisibly (note that in this case the original GTFS object is altered).
Visits are selected as in set_dwell_time(). At each selected visit whose
dwell time is shorter than min_dwell_time, the arrival time is kept and
the departure time is set to the arrival time plus min_dwell_time.
The first and last visits with both an arrival and a departure time of each
trip are never raised (use set_dwell_time() for them). They are found
among all the visits of the trip, not only the selected ones, and the times
of the last visit may still be shifted by an earlier visit.
Negative dwell times (departure earlier than arrival) are raised like any
other shorter dwell time, so a min_dwell_time of 0 raises only these.
When they come from times after midnight written as "00:30:00" instead of
"24:30:00", the later times of the trip are shifted by about a day.
Otherwise it works as set_dwell_time().
set_dwell_time(), get_dwell_time(), fix_gtfs()
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
# vehicles stay 0 seconds at the stops of this trip. make them stay at least
# 30 seconds at each intermediate stop
head(get_dwell_time(gtfs, trip_id = "CPTM L07-0"))
new_gtfs <- set_min_dwell_time(gtfs, 30, trip_id = "CPTM L07-0")
head(get_dwell_time(new_gtfs, trip_id = "CPTM L07-0"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.