View source: R/get_stop_times_patterns.R
| get_stop_times_patterns | R Documentation |
Identifies spatial and spatiotemporal patterns within the stop_times
table. Please see the details to understand what a "pattern" means in each of
these cases.
get_stop_times_patterns(gtfs, trip_id = NULL, type = "spatial", sort_sequence)
gtfs |
A GTFS object, as created by |
trip_id |
A character vector including the |
type |
A string specifying the type of patterns to be analyzed. Either
|
sort_sequence |
Deprecated; do not supply. Timetables are now always
sorted by |
A data.table associating each trip_id to a pattern_id.
Two trips are assigned to the same spatial pattern_id if they travel along
the same sequence of stops. They are assigned to the same spatiotemporal
pattern_id, on the other hand, if they travel along the same sequence of
stops and they take the same time between stops. Please note that, in such
case, only the time between stops is taken into account, and the time that
the trip started is ignored (e.g. if two trips depart from stop A and follow
the same sequence of stops to arrive at stop B, taking both 1 hour to do so,
their spatiotemporal pattern will be considered the same, even if one
departed at 6 am and another at 7 am). Please also note that only the order
given by stop_sequence matters, not its values - e.g. if trip X lists stops
A followed by stop B with stop_sequences 1 and 2, and trip Y lists stops A
followed by stop B with stop_sequences 1 and 3, they are assigned to the
same pattern_id.
Existing _secs columns in stop_times (e.g. created with
convert_time_to_seconds()) are used as-is, not recalculated from the time
strings.
data_path <- system.file("extdata/ber_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
patterns <- get_stop_times_patterns(gtfs)
head(patterns)
# use the trip_id argument to control which trips are analyzed
patterns <- get_stop_times_patterns(
gtfs,
trip_id = c("143765658", "143765659", "143765660")
)
patterns
# use the type argument to control the type of pattern analyzed
patterns <- get_stop_times_patterns(
gtfs,
trip_id = c("143765658", "143765659", "143765660"),
type = "spatiotemporal"
)
patterns
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.