This package provides a R interface to the Washington Metropolitan Area Transit Authority (WMATA) API
You can use this interface to query the WMATA API. For example, you can get the real time predictions for train arrivals at Metro Center (code A01):
library(wmata)
# get data
j <- next_trains("A01")
# show just the first 3 results
str(j$Trains[1:3], 2)
#> List of 3
#> $ :List of 9
#> ..$ Car : chr "8"
#> ..$ Destination : chr "Shady Gr"
#> ..$ DestinationCode: chr "A15"
#> ..$ DestinationName: chr "Shady Grove"
#> ..$ Group : chr "2"
#> ..$ Line : chr "RD"
#> ..$ LocationCode : chr "A01"
#> ..$ LocationName : chr "Metro Center"
#> ..$ Min : chr "2"
#> $ :List of 9
#> ..$ Car : chr "8"
#> ..$ Destination : chr "Takoma"
#> ..$ DestinationCode: chr "B07"
#> ..$ DestinationName: chr "Takoma"
#> ..$ Group : chr "1"
#> ..$ Line : chr "RD"
#> ..$ LocationCode : chr "A01"
#> ..$ LocationName : chr "Metro Center"
#> ..$ Min : chr "9"
#> $ :List of 9
#> ..$ Car : chr "8"
#> ..$ Destination : chr "Shady Gr"
#> ..$ DestinationCode: chr "A15"
#> ..$ DestinationName: chr "Shady Grove"
#> ..$ Group : chr "2"
#> ..$ Line : chr "RD"
#> ..$ LocationCode : chr "A01"
#> ..$ LocationName : chr "Metro Center"
#> ..$ Min : chr "14"
A data frame with mappings from stations to station codes is provided as the object stations
:
You can install the released version of wmata from GitHub with:
You will also have to sign up for a WMATA developer key at https://developer.wmata.com/. Once you get a key, edit your .Renviron file and place this line in there (replacing XXX with your key):
You can use usethis::edit_r_environ()
to edit your .Renviron file.