Learn R Programming

GTFSwizard (version 1.1.0)

get_frequency: Calculate Route Frequency in GTFS Data

Description

The `get_frequency` function calculates route frequency within a `wizardgtfs` object using different methods. Depending on the selected `method`, it can provide daily frequencies by route, shape, stop or detailed hourly frequencies.

Usage

get_frequency(gtfs, method = "by.route")

Value

A data frame containing route frequencies based on the specified method:

If `method = "by.route"`

Returns a data frame with columns: `route_id`, `direction_id`, `daily.frequency`, `service_pattern`, and `pattern_frequency`.

If `method = "by.shape"`

Returns a data frame with columns: `shape_id`, `direction_id`, `daily.frequency`, `service_pattern`, and `pattern_frequency`.

If `method = "by.stop"`

Returns a data frame with columns: `stop_id`, `direction_id`, `daily.frequency`, `service_pattern`, and `pattern_frequency`.

If `method = "detailed"`

Returns a data frame with columns: `route_id`, `direction_id`, `hour`, `frequency`, `service_pattern`, and `pattern_frequency`.

Arguments

gtfs

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

method

A character string specifying the calculation method. Options include:

"by.route"

Calculates the total daily frequency for each route.

"by.shape"

Calculates the total daily frequency for each shape.

"by.stop"

Calculates the total daily frequency for each stop.

"detailed"

Calculates the hourly frequency for each route.

Details

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

- "by.route": Calculates the total daily frequency for each route.

- "by.shape": Calculates the total daily frequency for each shape.

- "by.stop": Calculates the total daily frequency for each stop.

- "detailed": Provides an hourly breakdown of frequency, showing the number of departures per hour for each route and direction.

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

See Also

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

Examples

Run this code
# Calculate daily route frequency
frequency_by_route <- get_frequency(gtfs = for_rail_gtfs, method = "by.route")

# Calculate daily shape frequency
frequency_by_shape <- get_frequency(gtfs = for_rail_gtfs, method = "by.shape")

# Calculate daily stop frequency
frequency_by_stop <- get_frequency(gtfs = for_rail_gtfs, method = "by.stop")

# Calculate detailed hourly frequency
detailed_frequency <- get_frequency(gtfs = for_rail_gtfs, method = "detailed")

Run the code above in your browser using DataLab