This is equivalent to the NS reisplanner, you give in a from and to station, the timestamp, if you want the time to be your departure or arrival time, and optionally if you have a NS year card (has effect on some travels).
get_travel_advise(fromStation, toStation, dateTime = NULL,
departure = TRUE, yearCard = FALSE, hslAllowed = FALSE,
previousAdvises = 4, nextAdvises = 4)
the station to start from, for instance "Rotterdam Centraal"
the station to end, for instance "Utrecht Centraal"
defaults to current time, but you can use a different one: f.i. 2012-02-21T15:50, You can also use the datetime()
function.
is the datetime the start or end time? do you want to depart on that date or arrive, defaults to departure
if you have a NS year card (jaarabonnement) some trips will be different
use of the high speed train
how many advices do you want before the time
how many advises do you want after
A dataframe with travel advises around your chosen date time. Date time columns are formatted as time in "Europe/Amsterdam" timezone.
You can also specify how many trips before and after the chosen time you want to collect (defaults to 4, maximum is 5 before, and 5 after).
Some things to consider: station names need to be in Dutch but the NS
webservice also accepts shortened versions: "Utrecht Centraal" and
"ut" is apparently the same.
Station names can be found with the get_stationlist()
call.
Although the documentation https://www.ns.nl/en/travel-information/ns-api/documentation-travel-recommendations.html is in English, the returned values are all in Dutch. And I keep the results in Dutch.
# NOT RUN {
get_travel_advise("Amsterdam Centraal",
"Utrecht Centraal",dateTime = "2018-08-01T15:21",departure = TRUE)
# }
Run the code above in your browser using DataLab