retrieve_data: Retrieves a specific table from Statistics Denmark

Description Usage Arguments Value Examples

Description

The function retrieves a specific table from Statistics Denmark based on a table ID and some parameters to the API.

Usage

1
2
retrieve_data(table_id, ..., lang = "en",
  base_url = "http://api.statbank.dk/v1/")

Arguments

table_id

is the id of the table you want to call. You can get table ids by calling the retrieve_tables function.

...

are parameters you need to use to specify what data you want from the API. See the data created by the retrieve_metadata function. An * indicates ALL settings in the given parameter.

lang

whether to return the data in english or danish.

base_url

is the base url for the API you wish to call. Statistics Denmark can sometimes create custom API's that you can use by changing this parameter.

Value

a data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
metadata <- statsDK::retrieve_metadata("FOLK1A")
dplyr::glimpse(metadata)

# See the variables as a data frame
variables <- statsDK::get_variables(metadata)
dplyr::glimpse(variables)

# Use the param and the settings columns from the variables data to set the
# rigth values for the API call.
df_en <- statsDK::retrieve_data("PRIS111", VAREGR = "000000", ENHED = "*",
                                Tid = paste(paste0("2017M0", 1:8), collapse = ","))
dplyr::glimpse(df_en)

df_da <- statsDK::retrieve_data("PRIS111", VAREGR = "000000", ENHED = "*",
                                Tid = paste(paste0("2017M0", 1:8), collapse = ","),
                                lang = "da")
dplyr::glimpse(df_da)

statsDK documentation built on May 2, 2019, 4:19 a.m.