get_trip_segment_duration: Get trip segments' duration

Description Usage Arguments Value Details Examples

View source: R/get_trip_segment_duration.R

Description

Returns the duration of segments between stops of each specified trip_id.

Usage

1
get_trip_segment_duration(gtfs, trip_id = NULL, unit = "min")

Arguments

gtfs

A GTFS object as created by read_gtfs.

trip_id

A string vector including the trip_ids to have their segments' duration calculated. If NULL (the default) the function calculates the segments' duration of every trip_id in the GTFS.

unit

A string representing the time unit in which the duration is desired. One of "s" (seconds), "min" (minutes, the default), "h" (hours) or "d" (days).

Value

A data.table containing the segments' duration of each specified trip.

Details

A trip segment is defined as the path between two subsequent stops in the same trip. The duration of a segment is defined as the time difference between its arrival time and its departure time, as specified in the stop_times file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")

gtfs <- read_gtfs(data_path)

trip_segment_dur <- get_trip_segment_duration(gtfs)
head(trip_segment_dur)

trip_segment_dur <- get_trip_segment_duration(gtfs, trip_id = "CPTM L07-0")
trip_segment_dur

trip_segment_dur <- get_trip_segment_duration(gtfs, "CPTM L07-0", unit = "s")
trip_segment_dur

gtfstools documentation built on Feb. 23, 2021, 9:06 a.m.