genesisAPI: API Destatis Genesis

Description Usage Arguments Details Value Author(s) Examples

View source: R/genesisAPI.R

Description

Information retrieval from Destatis Genesis webservices

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
genesisAPI(api.param = stop("'api.param' must be specified"),
  service = stop("'service' must be specified"), curl = NULL,
  query = FALSE)

metaClean(s)

genesisXMLtoDF(xml.list = stop("'xml.list' must be provided"), meta = FALSE)

genesisDFtoXTS(data = stop("'data' must be provided"))

genesisTables(namefilter = c(11:14, 2, 3, 41:49, 5:9), fields = c("code",
  "beschriftungstext"), kennung = stop("'kennung' must be provided"),
  passwort = stop("'passwort' must be provided"), curl = NULL)

Arguments

api.param

a list with parameters used to construct the query, see example

service

the webservice to use, e.g. ExportService or RechercheService

curl

optional, CURL handle created with RCurl::getCurlHandle()

query

logical, return the https query

s

metadata string to convert to data frame

xml.list

a character string returned from

data

a data frame created with genesisXMLtoDF

namefilter

numeric vector to filter dataset codes.

fields

character vector to select fields from entries.

kennung

user ID.

passwort

user password.

curl

handle created with 'RCurl::getCurlHandle'.

Details

Retrieve information from Destatis Genesis quader in linearised XML format. The retrieval function requires a premium login https://www-genesis.destatis.de/genesis/online

Value

The main function creates an URL with with the specified parameters, retrieves the XML string and transforms into an R list. Additional functions convert the returned list to data frame and xts objects.

Author(s)

Bo Werth <[email protected]>

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Not run: 
api.param.datenexport <- list(
    method = "DatenExport",
    kennung = "KENNUNG",
    passwort = "PASSWORT",
    namen = "81000BJ002",
    bereich = "oeffentlich",
    format = "csv",
    werte = "true",
    metadaten = "false",
    zusatz = "false",
    startjahr = "",
    endjahr = "",
    zeitscheiben = "",
    regionalschluessel = "",
    sachmerkmal = "",
    sachschluessel = "",
    stand = "01.01.2001",
    sprache = "de"
)

curl <- RCurl::getCurlHandle()
## RCurl::curlSetOpt(.opts = list(proxy = ""), curl = curl)

xml.list.datenexport <- genesisAPI(api.param = api.param.datenexport,
                                   service = "ExportService",
                                   curl = curl)

## convert to data frame
data.df <- genesisXMLtoDF(xml.list = xml.list.datenexport)

## convert to xts object, e.g. for use in \code{dygraphs} package
data.xts <- genesisDFtoXTS(data = data.df)

## extract metadata
api.param.datenexport.meta <- 
 api.param.datenexport

api.param.datenexport.meta[["werte"]] <- "false"
api.param.datenexport.meta[["zusatz"]] <- "true"

xml.list.datenexport.meta <- genesisAPI(api.param = api.param.datenexport.meta,
                                        service = "ExportService",
                                        curl = ui.apiGENESIS.curl
                                        )

meta.df <- genesisXMLtoDF(xml.list = xml.list.datenexport.meta,
                          meta = TRUE)

## End(Not run)

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