patterns: Stopping pattern for a given run

Description Usage Arguments Details Value Examples

View source: R/patterns.R

Description

A pattern consists of all departures, stops, routes, runs, directions and disruptions associated with a particular run ID. This is returned as a list of tibbles, with output corresponding to their respective API calls.

Usage

1
2
3
4
5
6
7
8
patterns(
  run_ref,
  route_type,
  stop_id = NULL,
  departs = Sys.time(),
  user_id = determine_user_id(),
  api_key = determine_api_key()
)

Arguments

run_ref

A character run reference. This supersedes the integer run_id. For backwards compatibility and since most run references are integers, this function will attempt to convert an the argument to a character. Run references may be retrieved from the departures or runs_on_route functions.

route_type

Optionally filter results by a route type. A route type can be provided either as a non-negative integer code, or as a character: "Tram", "Train", "Bus", "Vline" or "Night Bus". Character inputs are not case-sensitive. Use the route_types function to extract a vector of all route types.

stop_id

Integer. Optionally filter results to a specific stop ID. These can be searched for with the stops_on_route and stops_nearby functions.

departs

POSIXct or character. Optionally filter by date. See Details. Characters are automatically converted to departs, and are assumed to be given as Melbourne time. The behaviour of the API is unpredictable when using this argument — see details. Defaults to the current system time.

user_id

Integer or character. A user ID or devid provided by Public Transport Victoria. Refer to ?ptvapi for more details.

api_key

Character. An API key, with dashes, provided by Public Transport Victoria. Refer to ?ptvapi for more details.

Details

The stops tibble has an output similar to that returned by stops_on_route. The routes tibble does not contain service status information.

Departures: The API seems to return the earliest 7 departures. While the PTV Timetable API supports filtering patterns by datetimes, the behaviour of this argument is not reliable — it appears to filter by day only, returning the earliest 7 departures of a different day. It is recommended that departures are retrieved via the departures function.

Value

An object of class "ptvapi", which is effectively a list with the following names:

Examples

1
2
3
4
5
## Not run: 
patterns(run_ref = "1", route_type = 0)
patterns(run_ref = "1", route_type = "Train")

## End(Not run)

ptvapi documentation built on May 2, 2021, 9:06 a.m.