get_dwelltimes: Calculate Dwell Times in GTFS Data

View source: R/get_dwelltimes.R

get_dwelltimesR Documentation

Calculate Dwell Times in GTFS Data

Description

The 'get_dwelltimes' function calculates dwell times within a 'wizardgtfs' object using different methods. Depending on the selected 'method', it can provide average dwell times per route, per trip, by hour, or detailed dwell times at each stop.

Usage

get_dwelltimes(gtfs, max.dwelltime = 90, method = "by.route")

Arguments

gtfs

A GTFS object, ideally of class 'wizardgtfs'. If not, it will be converted.

max.dwelltime

Numeric. The maximum allowable dwell time (in seconds). Dwell times exceeding this value are excluded from the calculations. Defaults to 90 seconds.

method

A character string specifying the calculation method. Options include:

"by.hour"

Calculates the average dwell time per hour of the day across all trips.

"by.route"

Calculates the average dwell time for each route.

"by.trip"

Calculates the average dwell time for each trip.

"detailed"

Calculates detailed dwell times at each stop within every trip.

Details

This function calls specific sub-functions based on the selected method:

- "by.hour": Calculates the average dwell time for each hour of the day.

- "by.route": Calculates average dwell times across each route.

- "by.trip": Calculates the total dwell time for each trip.

- "detailed": Calculates the dwell time between consecutive stops within each trip.

If an invalid 'method' is specified, the function defaults to '"by.route"' and provides a warning.

Value

A data frame containing dwell times based on the specified method:

If 'method = "by.hour"'

Returns a data frame with columns: 'hour', 'trips', 'average.dwelltime', 'service_pattern', and 'pattern_frequency'.

If 'method = "by.route"'

Returns a data frame with columns: 'route_id', 'trips', 'average.dwelltime', 'service_pattern', and 'pattern_frequency'.

If 'method = "by.trip"'

Returns a data frame with columns: 'route_id', 'trip_id', 'average.dwelltime', 'service_pattern', and 'pattern_frequency'.

If 'method = "detailed"'

Returns a data frame with columns: 'route_id', 'trip_id', 'stop_id', 'hour', 'dwell_time', 'service_pattern', and 'pattern_frequency'.

See Also

[GTFSwizard::as_wizardgtfs()], [GTFSwizard::get_servicepattern()]

Examples

# Calculate dwell times by hour
dwelltimes_by_hour <- get_dwelltimes(gtfs = for_rail_gtfs, max.dwelltime = 120, method = "by.hour")

# Calculate dwell times by route
dwelltimes_by_route <- get_dwelltimes(gtfs = for_rail_gtfs, max.dwelltime = 90, method = "by.route")

# Calculate dwell times by trip
dwelltimes_by_trip <- get_dwelltimes(gtfs = for_rail_gtfs, max.dwelltime = 45, method = "by.trip")

# Calculate detailed dwell times between stops
detailed_dwelltimes <- get_dwelltimes(gtfs = for_rail_gtfs, max.dwelltime = 60, method = "detailed")


GTFSwizard documentation built on April 4, 2025, 4:10 a.m.