Learn R Programming

ptvapi (version 2.0.5)

translate_route_type: Translate a route type input into a numerical route type

Description

Many API calls require a route type (eg. "Tram" or "Train"). These must be provided as integers, which are translated to route type descriptions with the `route_types() function/API call. This function will:

  • Translate a case-insensitive description such as "Tram" or "Train" to the corresponding route type code

  • Check a given integer to see if it is a valid route type code, returning it if so and erroring otherwise

  • Return NULL on NULL input

This function is not vectorised.

Usage

translate_route_type(
  route_type,
  user_id = determine_user_id(),
  api_key = determine_api_key()
)

Value

An integer route type code, or NULL if the input is NULL

Arguments

route_type

A route type which 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.

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.