This function connects to the UK National Grid's API for Data Item Explorer, which is a major data source for gas-related information. Internet connection must be available.
A vector of characters containing data items to enquire via API.
fromdate
A character object specifying the start date. Date is inclusive.
todate
A character object specifying the end date. Date is inclusive.
datetype
A character object specifying the data type. Defaults to gasday
latestflag
A character object with length of one to specify whether to extract the latest data. This can either be Y or N. Defaults to Y.
applicableforflag
A character object with length of one to specify whether dates specified are 'applicable for' or 'applicable on'. This can either be Y or N where Y indicates 'applicable for'. Defaults to Y.
apiurl
A character object which points to National Grid's SOAP API. Under most circumstances users do not have to change this. Defaults to 'http://marketinformation.natgrid.co.uk/MIPIws-public/public/publicwebservice.asmx'
Details
The function submits an enquiry to the destination API using XML over HTTP using SOAP standard. The HTTP response is in XML format which function will parse internally and return a R dataframe object.
# Specify the data item(s) to enquire from API
dataitems <- c('Storage Injection, Actual',
'Storage Withdrawal, Actual')
# Initialise API (requires internet connection for this step)
response <- dataItemExplorer(dataitems,
fromdate = '2013-10-01',
todate='2015-09-30')
# Visualise the results on a chart
library(ggplot2)
ggplot(response,aes(x=ApplicableFor,y=Value,colour=PublicationObjectName)) + geom_line()