Information retrieval from ONS webservices
onsAPI(method = "collections", context = "Economic", api.key = stop("'api.key' must be provided")) onsCsvData(api.param = stop("'api.param' must be provided"), dataset = stop("'dataset' must be provided"), query = FALSE, curl = NULL, ...) onsDFgather(data = stop("'data' must be provided"))
method | the API specific method, e.g. "collections" |
---|---|
context | the API specific context, e.g. "Economic" |
api.key | the API key |
api.param | a list with parameters used to construct the query, see examples. |
dataset | the dataset to download. |
query | logical, return the query containing the download link. |
curl | optional, |
data | a data frame created with |
The main function creates an URL with with the specified parameters, retrieves the zip file, extracts a csv file that is read into R and returned as data frame. Additional functions convert the returned data frame to an xts object.
Retrieve information from ONS API in CSV format.
# NOT RUN { onsAPI(method = "contexts", api.key = api.key) onsAPI(method = "collections", context = "Economic", api.key = api.key) # }## Within a group there is a series for each combination of dimension items in the segment. In a time series dataset there will be several observations within a series, but in the case of Census data there is only one time (Census Day 2011). api.param <- list(context = "Census", geog = "2011WARDH", totals = "false", apikey = "xPuqnMzZ01") data.QS208EW <- onsAPI(api.param = api.param, dataset = "QS208EW")#> Error in onsAPI(api.param = api.param, dataset = "QS208EW"): unused arguments (api.param = api.param, dataset = "QS208EW")data.QS104EW <- onsAPI(api.param = api.param, dataset = "QS104EW")#> Error in onsAPI(api.param = api.param, dataset = "QS104EW"): unused arguments (api.param = api.param, dataset = "QS104EW")