onsAPI: API ONS

Description Usage Arguments Details Value Author(s) Examples

View source: R/onsAPI.R

Description

Information retrieval from ONS webservices

Usage

1
2
3
4
5
6
7
8
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"))

Arguments

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, CURL handle created with RCurl::getCurlHandle().

data

a data frame created with onsAPI

Details

Retrieve information from ONS API in CSV format.

Value

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.

Author(s)

Bo Werth <[email protected]>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
onsAPI(method = "contexts", api.key = api.key)
onsAPI(method = "collections", context = "Economic", api.key = api.key)

## End(Not run)
## 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")
data.QS104EW <- onsAPI(api.param = api.param, dataset = "QS104EW")

bowerth/nsoApi documentation built on July 1, 2017, 11 p.m.