sdmxRead: Query Data OECD.Stat

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Query data from OECD.Stat using SDMX

splitSdmxRead: create query for part of dataset and write to disk

exportCodes: write codelist to disk

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
sdmxRead(api = "http://stats.oecd.org/SDMX-JSON", scheme = "data",
  DSD = "BTDIXE_I4", filter = list(COU = c("ESP", "DEU"), FLW = c("IMPO"),
  PAR = c("WOR"), EUC = c("TOTAL", "INT"), IND = c("DTOTAL", "D01T03"), VAL =
  c("VALUE")), append = paste0("/all?", paste("json-lang=en", "detail=Full",
  "dimensionAtObservation=AllDimensions", "startPeriod=2000", "endPeriod=2010",
  sep = "&")), query = FALSE)

splitSdmxRead(id, split_dim, codelist, destdir, start, end)

exportCodes(codelist, destdir, prefix)

loadJSON(loc)

transformData(x, elem = "dataSets", extractNames = FALSE)

factorLevels(x, elem = "structure")

names2df(names, factor_levels)

assignFactors(data, factor_levels)

processFile(loc)

Arguments

api

an API address

scheme

an API scheme. Available schemes data, codelist.

DSD

a datastructure definition identified by the triplet [collection; country; indicator].

filter

for scheme "data": a named list of filters passed to the API. The position of list items corresponds to the API filter dimensions. Each list item is either empty (no filter on dimension) or a character vector containing dimension members to be included in the results. Dimension members can be obtained from scheme="codelist" and a codelist item, e.g. "CL_ECO_ISIC4".

append

append string to the dimension url.

query

logical to return SDMX http url only.

id

member of split_dim

split_dim

dimension to be split

codelist

created by sdmxRead using {codelist} scheme

destdir

local directory to export results

start

integer value query start year

end

integer value query end year

prefix

character string appended to export file

Details

Helper function to efficiently query data from OECD.Stat Extracts using SDMX-JSON API.

splitSdmxRead(loc, split_dim, codelist, destdir, start, end)

exportCodes(codelist, destdir, prefix)

Value

exporting one json file per dimension member of {split_dim}

a tab-separated codelist file for each dimension

Author(s)

Bo Werth <bo.werth@gmail.com>

See Also

https://data.oecd.org/api/sdmx-json-documentation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 
## list dimension members
test.codelist <- sdmxRead(DSD = "BTDIXE_I4", scheme = "codelist")
## retrieve data
filter.list <- list(COU = c("ESP", "DEU"),
                    FLW = c("IMPO"),
                    PAR = c("WOR"),
                    EUC = c("TOTAL", "INT"),
                    IND = c("DTOTAL", "D01T03"),
                    VAL = c("VALUE"))
url.append <- paste0("/all?",
                     paste("json-lang=en", "detail=Full",
                           "dimensionAtObservation=AllDimensions",
                           "startPeriod=1990", "endPeriod=2000",
                           sep = "&"))
test.data <- sdmxRead(DSD = "BTDIXE_I4", filter = filter.list)

## End(Not run)
library(doMC)
registerDoMC(detectCores(logical = TRUE) - 1)
flow <- "TEC7_REV4"
src_id <- tolower(flow)
codelist <- nsoApi::sdmxRead(DSD = flow, scheme = "codelist")
split_dim <- "REPORTER"
namecou <- codelist[[split_dim]][["id"]]
foreach(cou = namecou) %dopar% splitSdmxRead(id = cou, codelist = codelist, destdir = file.path(origdir, src_id))
codelist <- nsoApi::sdmxRead(DSD = "TEC7_REV4", scheme = "codelist")
exportCodes(codelist = codelist, destdir = ".", prefix = paste0("_"))

bowerth/nsoApi documentation built on June 17, 2019, 4:55 a.m.