Title: | An Interface to the National Rail Enquiries Systems |
---|---|
Description: | The goal of 'trainR' is to provide a simple interface to the National Rail Enquiries (NRE) systems. There are few data feeds available, the simplest of them is Darwin, which provides real-time arrival and departure predictions, platform numbers, delay estimates, schedule changes and cancellations. Other data feeds provide historical data, Historic Service Performance (HSP), and much more. 'trainR' simplifies the data retrieval, so that the users can focus on their analyses. For more details visit <https://www.nationalrail.co.uk/46391.aspx>. |
Authors: | Roberto Villegas-Diaz [aut, cre] |
Maintainer: | Roberto Villegas-Diaz <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.1.9000 |
Built: | 2024-11-21 03:19:49 UTC |
Source: | https://github.com/villegar/trainr |
Get CRS code from a string with the station name.
get_crs(station, ...)
get_crs(station, ...)
station |
String with the station name, partial names are allowed. |
... |
Arguments passed on to
|
Vector of strings with the matched CRS codes, or NULL
if no
match is found.
trainR::get_crs("London") trainR::get_crs("Manchester") trainR::get_crs("manchester", ignore.case = TRUE)
trainR::get_crs("London") trainR::get_crs("Manchester") trainR::get_crs("manchester", ignore.case = TRUE)
Get user's token to access the National Rail Enquiries (NRE) data feeds.
get_token(ENV = "NRE")
get_token(ENV = "NRE")
ENV |
String with environment variable containing the token to access the NRE data feeds (default = "NRE"). |
String with token.
Get all public arrivals for the supplied CRS code within a defined time window.
GetArrBoardRequest( crs, filterCrs = NA, filterType = "from", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
GetArrBoardRequest( crs, filterCrs = NA, filterType = "from", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
crs |
(string, 3 characters, alphabetic): The CRS code of the location for which the request is being made. |
filterCrs |
(string, 3 characters, alphabetic): The CRS code of either an origin or destination location to filter in. Optional. |
filterType |
(string, either "from" or "to"): The type of filter to
apply. Filters services to include only those originating or terminating
at the |
numRows |
(integer, between 0 and 150 exclusive): The number of services to return in the resulting station board. |
timeOffset |
(integer, between -120 and 120 exclusive): An offset in minutes against the current time to provide the station board for. Defaults to 0. |
timeWindow |
(integer, between -120 and 120 exclusive): How far into
the future in minutes, relative to |
token |
Token to access the data feed. The token can be obtained at http://realtime.nationalrail.co.uk/OpenLDBWSRegistration/. |
url |
Data feed source URL. |
verbose |
Boolean flag to indicate whether or not to show status messages. |
Tibble with arrival records. Each column is described below:
The time at which the station board was generated.
The name of the location that the station board is for.
The CRS code of the location that the station board is for.
If a filter was requested, the location name of the filter location.
If a filter was requested, the CRS code of the filter location.
If a filter was requested, the type of filter.
An optional list of textual messages that should be
displayed with the station board. The message may include embedded and XML
encoded HTML-like hyperlinks and paragraphs. The messages are typically
used to display important disruption information that applies to the
location that the station board was for. Any embedded <p>
tags are
used to force a new-line in the output. Embedded <a>
tags allow
links to external web pages that may provide more information. Output
channels that do not support HTML should strip out the <a>
tags and
just leave the enclosed text.
An optional value that indicates if platform information is available. If this value is present with the value "true" then platform information will be returned in the service lists. If this value is not present, or has the value "false", then the platform "heading" should be suppressed in the user interface for this station board.
An optional value that indicates if services
are currently available for this station board. If this value is present
with the value "false" then no services will be returned in the service
lists. This value may be set, for example, if access to a station has been
closed to the public at short notice, even though the scheduled services
are still running. It would be usual in such cases for one of the
nrccMessages
to describe why the list of services has been
suppressed.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
Documentation for the Live Departure Boards Web Service (LDBWS / OpenLDBWS): http://lite.realtime.nationalrail.co.uk/openldbws/
Other OpenLDBSVWS requests:
GetArrBoardWithDetailsRequest()
,
GetArrDepBoardWithDetailsRequest()
,
GetDepBoardRequest()
,
GetDepBoardWithDetailsRequest()
,
GetServiceDetailsRequest()
## Not run: rdg_arr <- trainR::GetArrBoardRequest("RDG") rdg_arr <- trainR::GetArrBoardRequest("RDG", filterCrs = "BRI") trainR::print(rdg_arr) ## End(Not run)
## Not run: rdg_arr <- trainR::GetArrBoardRequest("RDG") rdg_arr <- trainR::GetArrBoardRequest("RDG", filterCrs = "BRI") trainR::print(rdg_arr) ## End(Not run)
Get all public arrivals for the supplied CRS code within a defined time window, including service details.
GetArrBoardWithDetailsRequest( crs, filterCrs = NA, filterType = "from", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
GetArrBoardWithDetailsRequest( crs, filterCrs = NA, filterType = "from", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
crs |
(string, 3 characters, alphabetic): The CRS code of the location for which the request is being made. |
filterCrs |
(string, 3 characters, alphabetic): The CRS code of either an origin or destination location to filter in. Optional. |
filterType |
(string, either "from" or "to"): The type of filter to
apply. Filters services to include only those originating or terminating
at the |
numRows |
(integer, between 0 and 150 exclusive): The number of services to return in the resulting station board. |
timeOffset |
(integer, between -120 and 120 exclusive): An offset in minutes against the current time to provide the station board for. Defaults to 0. |
timeWindow |
(integer, between -120 and 120 exclusive): How far into
the future in minutes, relative to |
token |
Token to access the data feed. The token can be obtained at http://realtime.nationalrail.co.uk/OpenLDBWSRegistration/. |
url |
Data feed source URL. |
verbose |
Boolean flag to indicate whether or not to show status messages. |
Tibble with arrival records. Each column is described below:
The time at which the station board was generated.
The name of the location that the station board is for.
The CRS code of the location that the station board is for.
If a filter was requested, the location name of the filter location.
If a filter was requested, the CRS code of the filter location.
If a filter was requested, the type of filter.
An optional list of textual messages that should be
displayed with the station board. The message may include embedded and XML
encoded HTML-like hyperlinks and paragraphs. The messages are typically
used to display important disruption information that applies to the
location that the station board was for. Any embedded <p>
tags are
used to force a new-line in the output. Embedded <a>
tags allow
links to external web pages that may provide more information. Output
channels that do not support HTML should strip out the <a>
tags and
just leave the enclosed text.
An optional value that indicates if platform information is available. If this value is present with the value "true" then platform information will be returned in the service lists. If this value is not present, or has the value "false", then the platform "heading" should be suppressed in the user interface for this station board.
An optional value that indicates if services
are currently available for this station board. If this value is present
with the value "false" then no services will be returned in the service
lists. This value may be set, for example, if access to a station has been
closed to the public at short notice, even though the scheduled services
are still running. It would be usual in such cases for one of the
nrccMessages
to describe why the list of services has been
suppressed.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
Documentation for the Live Departure Boards Web Service (LDBWS / OpenLDBWS): http://lite.realtime.nationalrail.co.uk/openldbws/
Other OpenLDBSVWS requests:
GetArrBoardRequest()
,
GetArrDepBoardWithDetailsRequest()
,
GetDepBoardRequest()
,
GetDepBoardWithDetailsRequest()
,
GetServiceDetailsRequest()
## Not run: rdg_arr <- trainR::GetArrBoardWithDetailsRequest("RDG") rdg_arr <- trainR::GetArrBoardWithDetailsRequest("RDG", filterCrs = "BRI") trainR::print(rdg_arr) ## End(Not run)
## Not run: rdg_arr <- trainR::GetArrBoardWithDetailsRequest("RDG") rdg_arr <- trainR::GetArrBoardWithDetailsRequest("RDG", filterCrs = "BRI") trainR::print(rdg_arr) ## End(Not run)
Get all public arrivals and departures for the supplied CRS code within a defined time window, including service details.
GetArrDepBoardWithDetailsRequest( crs, filterCrs = NA, filterType = "from", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
GetArrDepBoardWithDetailsRequest( crs, filterCrs = NA, filterType = "from", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
crs |
(string, 3 characters, alphabetic): The CRS code of the location for which the request is being made. |
filterCrs |
(string, 3 characters, alphabetic): The CRS code of either an origin or destination location to filter in. Optional. |
filterType |
(string, either "from" or "to"): The type of filter to
apply. Filters services to include only those originating or terminating
at the |
numRows |
(integer, between 0 and 150 exclusive): The number of services to return in the resulting station board. |
timeOffset |
(integer, between -120 and 120 exclusive): An offset in minutes against the current time to provide the station board for. Defaults to 0. |
timeWindow |
(integer, between -120 and 120 exclusive): How far into
the future in minutes, relative to |
token |
Token to access the data feed. The token can be obtained at http://realtime.nationalrail.co.uk/OpenLDBWSRegistration/. |
url |
Data feed source URL. |
verbose |
Boolean flag to indicate whether or not to show status messages. |
Tibble with arrival and departure records. Each column is described below:
The time at which the station board was generated.
The name of the location that the station board is for.
The CRS code of the location that the station board is for.
If a filter was requested, the location name of the filter location.
If a filter was requested, the CRS code of the filter location.
If a filter was requested, the type of filter.
An optional list of textual messages that should be
displayed with the station board. The message may include embedded and XML
encoded HTML-like hyperlinks and paragraphs. The messages are typically
used to display important disruption information that applies to the
location that the station board was for. Any embedded <p>
tags are
used to force a new-line in the output. Embedded <a>
tags allow
links to external web pages that may provide more information. Output
channels that do not support HTML should strip out the <a>
tags and
just leave the enclosed text.
An optional value that indicates if platform information is available. If this value is present with the value "true" then platform information will be returned in the service lists. If this value is not present, or has the value "false", then the platform "heading" should be suppressed in the user interface for this station board.
An optional value that indicates if services
are currently available for this station board. If this value is present
with the value "false" then no services will be returned in the service
lists. This value may be set, for example, if access to a station has been
closed to the public at short notice, even though the scheduled services
are still running. It would be usual in such cases for one of the
nrccMessages
to describe why the list of services has been
suppressed.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
Documentation for the Live Departure Boards Web Service (LDBWS / OpenLDBWS): http://lite.realtime.nationalrail.co.uk/openldbws/
Other OpenLDBSVWS requests:
GetArrBoardRequest()
,
GetArrBoardWithDetailsRequest()
,
GetDepBoardRequest()
,
GetDepBoardWithDetailsRequest()
,
GetServiceDetailsRequest()
## Not run: rdg<- trainR::GetArrDepBoardWithDetailsRequest("RDG") rdg <- trainR::GetArrDepBoardWithDetailsRequest("RDG", filterCrs = "BRI") trainR::print(rdg) ## End(Not run)
## Not run: rdg<- trainR::GetArrDepBoardWithDetailsRequest("RDG") rdg <- trainR::GetArrDepBoardWithDetailsRequest("RDG", filterCrs = "BRI") trainR::print(rdg) ## End(Not run)
Get all public departures for the supplied CRS code within a defined time window.
GetDepBoardRequest( crs, filterCrs = NA, filterType = "to", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
GetDepBoardRequest( crs, filterCrs = NA, filterType = "to", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
crs |
(string, 3 characters, alphabetic): The CRS code of the location for which the request is being made. |
filterCrs |
(string, 3 characters, alphabetic): The CRS code of either an origin or destination location to filter in. Optional. |
filterType |
(string, either "from" or "to"): The type of filter to
apply. Filters services to include only those originating or terminating
at the |
numRows |
(integer, between 0 and 150 exclusive): The number of services to return in the resulting station board. |
timeOffset |
(integer, between -120 and 120 exclusive): An offset in minutes against the current time to provide the station board for. Defaults to 0. |
timeWindow |
(integer, between -120 and 120 exclusive): How far into
the future in minutes, relative to |
token |
Token to access the data feed. The token can be obtained at http://realtime.nationalrail.co.uk/OpenLDBWSRegistration/. |
url |
Data feed source URL. |
verbose |
Boolean flag to indicate whether or not to show status messages. |
Tibble with departure records. Each column is described below:
The time at which the station board was generated.
The name of the location that the station board is for.
The CRS code of the location that the station board is for.
If a filter was requested, the location name of the filter location.
If a filter was requested, the CRS code of the filter location.
If a filter was requested, the type of filter.
An optional list of textual messages that should be
displayed with the station board. The message may include embedded and XML
encoded HTML-like hyperlinks and paragraphs. The messages are typically
used to display important disruption information that applies to the
location that the station board was for. Any embedded <p>
tags are
used to force a new-line in the output. Embedded <a>
tags allow
links to external web pages that may provide more information. Output
channels that do not support HTML should strip out the <a>
tags and
just leave the enclosed text.
An optional value that indicates if platform information is available. If this value is present with the value "true" then platform information will be returned in the service lists. If this value is not present, or has the value "false", then the platform "heading" should be suppressed in the user interface for this station board.
An optional value that indicates if services
are currently available for this station board. If this value is present
with the value "false" then no services will be returned in the service
lists. This value may be set, for example, if access to a station has been
closed to the public at short notice, even though the scheduled services
are still running. It would be usual in such cases for one of the
nrccMessages
to describe why the list of services has been
suppressed.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
Documentation for the Live Departure Boards Web Service (LDBWS / OpenLDBWS): http://lite.realtime.nationalrail.co.uk/openldbws/
Other OpenLDBSVWS requests:
GetArrBoardRequest()
,
GetArrBoardWithDetailsRequest()
,
GetArrDepBoardWithDetailsRequest()
,
GetDepBoardWithDetailsRequest()
,
GetServiceDetailsRequest()
## Not run: rdg_dep <- trainR::GetDepBoardRequest("RDG") rdg_dep <- trainR::GetDepBoardRequest("RDG", filterCrs = "BRI") trainR::print(rdg_dep) ## End(Not run)
## Not run: rdg_dep <- trainR::GetDepBoardRequest("RDG") rdg_dep <- trainR::GetDepBoardRequest("RDG", filterCrs = "BRI") trainR::print(rdg_dep) ## End(Not run)
Get all public departures for the supplied CRS code within a defined time window, including service details.
GetDepBoardWithDetailsRequest( crs, filterCrs = NA, filterType = "to", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
GetDepBoardWithDetailsRequest( crs, filterCrs = NA, filterType = "to", numRows = 150, timeOffset = 0, timeWindow = 120, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
crs |
(string, 3 characters, alphabetic): The CRS code of the location for which the request is being made. |
filterCrs |
(string, 3 characters, alphabetic): The CRS code of either an origin or destination location to filter in. Optional. |
filterType |
(string, either "from" or "to"): The type of filter to
apply. Filters services to include only those originating or terminating
at the |
numRows |
(integer, between 0 and 150 exclusive): The number of services to return in the resulting station board. |
timeOffset |
(integer, between -120 and 120 exclusive): An offset in minutes against the current time to provide the station board for. Defaults to 0. |
timeWindow |
(integer, between -120 and 120 exclusive): How far into
the future in minutes, relative to |
token |
Token to access the data feed. The token can be obtained at http://realtime.nationalrail.co.uk/OpenLDBWSRegistration/. |
url |
Data feed source URL. |
verbose |
Boolean flag to indicate whether or not to show status messages. |
Tibble with departure records. Each column is described below:
The time at which the station board was generated.
The name of the location that the station board is for.
The CRS code of the location that the station board is for.
If a filter was requested, the location name of the filter location.
If a filter was requested, the CRS code of the filter location.
If a filter was requested, the type of filter.
An optional list of textual messages that should be
displayed with the station board. The message may include embedded and XML
encoded HTML-like hyperlinks and paragraphs. The messages are typically
used to display important disruption information that applies to the
location that the station board was for. Any embedded <p>
tags are
used to force a new-line in the output. Embedded <a>
tags allow
links to external web pages that may provide more information. Output
channels that do not support HTML should strip out the <a>
tags and
just leave the enclosed text.
An optional value that indicates if platform information is available. If this value is present with the value "true" then platform information will be returned in the service lists. If this value is not present, or has the value "false", then the platform "heading" should be suppressed in the user interface for this station board.
An optional value that indicates if services
are currently available for this station board. If this value is present
with the value "false" then no services will be returned in the service
lists. This value may be set, for example, if access to a station has been
closed to the public at short notice, even though the scheduled services
are still running. It would be usual in such cases for one of the
nrccMessages
to describe why the list of services has been
suppressed.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
A list of ServiceItem
object for each services
of the relevant type that is to appear on the station board. May contain
zero items, or may not be present at all.
Documentation for the Live Departure Boards Web Service (LDBWS / OpenLDBWS): http://lite.realtime.nationalrail.co.uk/openldbws/
Other OpenLDBSVWS requests:
GetArrBoardRequest()
,
GetArrBoardWithDetailsRequest()
,
GetArrDepBoardWithDetailsRequest()
,
GetDepBoardRequest()
,
GetServiceDetailsRequest()
## Not run: rdg_dep <- trainR::GetDepBoardWithDetailsRequest("RDG") rdg_dep <- trainR::GetDepBoardWithDetailsRequest("RDG", filterCrs = "BRI") trainR::print(rdg_dep) ## End(Not run)
## Not run: rdg_dep <- trainR::GetDepBoardWithDetailsRequest("RDG") rdg_dep <- trainR::GetDepBoardWithDetailsRequest("RDG", filterCrs = "BRI") trainR::print(rdg_dep) ## End(Not run)
Get the service details for a specific service identified by a station board.
These details are supplied relative to the station board from which the
serviceID
field value was generated. Service details are only
available while the service appears on the station board from which it was
obtained. This is normally for two minutes after it is expected to have
departed, or after a terminal arrival. If a request is made for a service
that is no longer available then a NULL
value is returned.
GetServiceDetailsRequest( serviceID, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
GetServiceDetailsRequest( serviceID, token = get_token(), url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx", verbose = FALSE )
serviceID |
(string): The LDBWS service ID of the service to request
the details of. The service ID is obtained from a service listed in a
|
token |
Token to access the data feed. The token can be obtained at http://realtime.nationalrail.co.uk/OpenLDBWSRegistration/. |
url |
Data feed source URL. |
verbose |
Boolean flag to indicate whether or not to show status messages. |
Tibble with departure records.
Other OpenLDBSVWS requests:
GetArrBoardRequest()
,
GetArrBoardWithDetailsRequest()
,
GetArrDepBoardWithDetailsRequest()
,
GetDepBoardRequest()
,
GetDepBoardWithDetailsRequest()
Configure user's token to access the National Rail Enquiries (NRE) data feeds.
set_token()
set_token()
To obtain an access token, you must complete the registration form found at http://realtime.nationalrail.co.uk/OpenLDBWSRegistration/.
Nothing, helper function to set up environment variable.
A dataset containing information of 2579 British National Rail Enquiries (NRE) station 3 letter alpha (CRS) codes.
data(station_codes)
data(station_codes)
A data frame with 2579 rows and 2 variables:
Station name.
Station code.
National Rail Enquiries (NRE)
https://www.nationalrail.co.uk/stations_destinations/48541.aspx
store(x, ...) ## S3 method for class 'StationBoard' store(x, ..., file) ## S3 method for class 'busServices' store(x, ..., wb) ## S3 method for class 'ferryServices' store(x, ..., wb) ## S3 method for class 'trainServices' store(x, ..., wb) ## S3 method for class 'CallingPoints' store(x, ..., wb, serviceID) ## S3 method for class 'previousCallingPoints' store(x, ..., wb, serviceID) ## S3 method for class 'subsequentCallingPoints' store(x, ..., wb, serviceID)
store(x, ...) ## S3 method for class 'StationBoard' store(x, ..., file) ## S3 method for class 'busServices' store(x, ..., wb) ## S3 method for class 'ferryServices' store(x, ..., wb) ## S3 method for class 'trainServices' store(x, ..., wb) ## S3 method for class 'CallingPoints' store(x, ..., wb, serviceID) ## S3 method for class 'previousCallingPoints' store(x, ..., wb, serviceID) ## S3 method for class 'subsequentCallingPoints' store(x, ..., wb, serviceID)
x |
Data. |
... |
Optional parameters. |
file |
String with filename and path. |
wb |
Workbook object, created with
|
serviceID |
(string): The LDBWS service ID of the service to request
the details of. The service ID is obtained from a service listed in a
|
The goal of this generic is to facilitate storing data retrieved from arrival and departure boards. Each request has multiple parts that should be stored individually (e.g. Excel Workbook or individual CSV files).
Nothing, call for its side effect.
## Not run: `%>%` <- magrittr::`%>%` pad <- trainR::GetArrBoardWithDetailsRequest("PAD") pad %>% trainR::store(file = "arrivals-PAD.xlsx") # Delete test file unlink("arrivals-PAD.xlsx") ## End(Not run)
## Not run: `%>%` <- magrittr::`%>%` pad <- trainR::GetArrBoardWithDetailsRequest("PAD") pad %>% trainR::store(file = "arrivals-PAD.xlsx") # Delete test file unlink("arrivals-PAD.xlsx") ## End(Not run)