next_train: Next Trains

View source: R/next-train.R

next_trainR Documentation

Next Trains

Description

Returns next train arrival information for one or more stations. Will return an empty set of results when no predictions are available. Use "All" for the StationCodes parameter to return predictions for all stations.

Usage

next_train(StationCodes = NULL, api_key = wmata_key())

Arguments

StationCodes

Character vector of station codes. For all predictions, use NULL (default) or "All".

api_key

Subscription key which provides access to this API. Defaults Sys.getenv("WMATA_KEY") via wmata_key().

Format

A tibble 1 row per arrival with 9 variables:

Car

Number of cars on a train, usually 6 or 8, but might also NA.

Destination

Abbreviated version of the final destination for a train. This is similar to what is displayed on the signs at stations.

DestinationCode

Destination station code. Can be NA. Use this value in other rail-related APIs to retrieve data about a station.

DestinationName

When DestinationCode is populated, this is the full name of the destination station, as shown on the WMATA website.

Group

Denotes the track this train is on, but does not necessarily equate to Track 1 or Track 2. With the exception of terminal stations, predictions at the same station with different Group values refer to trains on different tracks.

Line

Two-letter abbreviation for the line (e.g.: RD, BL, YL, OR, GR, or SV). May also be NA for trains with no passengers.

LocationCode

Station code for where the train is arriving. Useful when passing in All as the StationCodes parameter. Use this value in other rail-related APIs to retrieve data about a station.

LocationName

Full name of the station where the train is arriving. Useful when passing in "All" as the StationCodes parameter.

Min

Minutes until arrival. Can be a numeric value, 0 (arriving), -1 (boarding), or NA.

Details

For terminal stations (e.g.: Greenbelt, Shady Grove, etc.), predictions may be displayed twice.

Some stations have two platforms (e.g.: Gallery Place, Fort Totten, L'Enfant Plaza, and Metro Center). To retrieve complete predictions for these stations, be sure to pass in both StationCodes.

For trains with no passengers, the DestinationName will be "No Passenger".

Value

Data frame of train arrivals.

See Also

https://developer.wmata.com/docs/services/547636a6f9182302184cda78/operations/547636a6f918230da855363f

Other Real-Time Predictions: next_bus()

Examples

## Not run: 
next_train(StationCodes = c("A02", "B02"))

## End(Not run)

metro documentation built on Nov. 2, 2023, 6:06 p.m.