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.
patterns(
run_ref,
route_type,
stop_id = NULL,
departs = Sys.time(),
user_id = determine_user_id(),
api_key = determine_api_key()
)
An object of class "ptvapi", which is effectively a list with the following names:
departures
stops
routes
runs
directions
disruptions
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.
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.
Integer. Optionally filter results to a specific stop ID.
These can be searched for with the stops_on_route
and stops_nearby
functions.
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.
Integer or character. A user ID or devid provided by Public
Transport Victoria. Refer to ?ptvapi
for more details.
Character. An API key, with dashes, provided by Public
Transport Victoria. Refer to ?ptvapi
for more 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.
if (FALSE) {
patterns(run_ref = "1", route_type = 0)
patterns(run_ref = "1", route_type = "Train")
}
Run the code above in your browser using DataLab