Returns opening and scheduled first/last train times based on a given StationCode. Omit the StationCode to return timing information for all stations.

rail_times(StationCode = NULL, api_key = wmata_key())

Arguments

StationCode

Station code. Use the rail_stations() function to return a list of all station codes. Use NULL (default) to return times for all stations.

api_key

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

Format

A tibble 1 row per train with 8 variables:

StationCode

Station code for this station. Use this value in other rail-related APIs to retrieve data about a station.

StationName

Full name of the station.

DestinationStation

Station code for the train's destination. Use this value in other rail-related APIs to retrieve data about a station.

Weekday

Day of the week abbreviation. From list element names.

OpeningTime

Station opening time. Converted to hms class with hms::parse_hm(), representing seconds since midnight of that Weekday.

FirstTime

First train leaves the station at this time (ET). Converted to hms class with hms::parse_hm(), representing seconds since midnight of that Weekday.

LastTime

Last train leaves the station at this time (ET). Converted to hms class with hms::parse_hm(), representing seconds since midnight of that Weekday. For times that were in the AM of the next Weekday, time is greater than 24 hours.

Value

A tidy data frame of station schedules. Combined from a nested list of weekday times.

Details

Note that for stations with multiple platforms (e.g.: Metro Center, L'Enfant Plaza, etc.), a distinct call is required for each StationCode to retrieve the full set of train times at such stations.

See also

Examples

if (FALSE) { rail_times("A01") }