Learn R Programming

rdbnomics (version 0.4.3)

rdb: Download DBnomics data.

Description

rdb downloads data series from DBnomics.

Usage

rdb(provider_code = NULL, dataset_code = NULL, ids = NULL,
  dimensions = NULL, mask = NULL,
  api_base_url = "https://api.db.nomics.world/series?",
  verbose = getOption("rdbnomics.verbose_warning"), ...)

Arguments

provider_code

Character string. DBnomics code of the provider.

dataset_code

Character string. DBnomics code of the dataset.

ids

Character string. DBnomics code of one or several series.

dimensions

Character string (single quote). DBnomics code of one or several dimensions in the specified provider and dataset.

mask

Character string. DBnomics code of one or several dimensions in the specified provider and dataset.

api_base_url

Character string. DBnomics API link.

verbose

Logical (default getOption("rdbnomics.verbose_warning")). Show warnings of the function.

...

Arguments to be passed to rdb_by_api_link. For example, you can set use_readLines = TRUE to request and read the data with the base function readLines. This can be used to get round the error Could not resolve host: api.db.nomics.world.

Value

A data.frame.

Details

This function gives you access to hundreds of millions data series from DBnomics API (documentation about the API can be found here). The code of each series is given on the DBnomics website.

See Also

rdb_by_api_link

Examples

Run this code
# NOT RUN {
# By ids
# Fetch one series from dataset 'Unemployment rate' (ZUTN) of AMECO provider:
df1 <- rdb(ids='AMECO/ZUTN/EA19.1.0.0.0.ZUTN')
# Fetch two series from dataset 'Unemployment rate' (ZUTN) of AMECO provider:
df2 <- rdb(ids=c('AMECO/ZUTN/EA19.1.0.0.0.ZUTN','AMECO/ZUTN/DNK.1.0.0.0.ZUTN'))
# Fetch two series from different datasets of different providers:
df3 <- rdb(ids=c('AMECO/ZUTN/EA19.1.0.0.0.ZUTN','IMF/CPI/A.AT.PCPIT_IX'))

# By dimensions
# Fetch one value of one dimension from dataset 'Unemployment rate' (ZUTN) of AMECO provider:
df1 <- rdb('AMECO','ZUTN',dimensions='{"geo": ["ea12"]}')
# Fetch two values of one dimension from dataset 'Unemployment rate' (ZUTN) of AMECO provider:
df2 <- rdb('AMECO','ZUTN',dimensions='{"geo": ["ea12", "dnk"]}')
# Fetch several values of several dimensions from dataset 'Doing business' (DB) of World Bank:
dim <- '{"country": ["DZ", "PE"],"indicator": ["ENF.CONT.COEN.COST.ZS","IC.REG.COST.PC.FE.ZS"]}'
df3 <- rdb('WB', 'DB', dimensions = dim)

# By mask (only for some providers, check the list here :
# https://git.nomics.world/dbnomics/dbnomics-api/blob/master/dbnomics_api/application.cfg.)
# Fetch one series from dataset 'Consumer Price Index' (CPI) of IMF:
df1 <- rdb('IMF','CPI',mask='M.DE.PCPIEC_WT')
# Fetch two series from dataset 'Consumer Price Index' (CPI) of IMF:
df2 <- rdb('IMF','CPI',mask='M.DE+FR.PCPIEC_WT')
# Fetch all series along one dimension from dataset 'Consumer Price Index' (CPI) of IMF:
df3 <- rdb('IMF','CPI',mask='M..PCPIEC_WT')
# Fetch series along multiple dimensions from dataset 'Consumer Price Index' (CPI) of IMF:
df4 <- rdb('IMF','CPI',mask='M..PCPIEC_IX+PCPIA_IX')

# Use readLines before fromJSON to avoid a proxy failure
# Fetch one series from dataset 'Unemployment rate' (ZUTN) of AMECO provider:
options(rdbnomics.use_readLines = TRUE)
df1 <- rdb(ids='AMECO/ZUTN/EA19.1.0.0.0.ZUTN')
# or
df1 <- rdb(ids='AMECO/ZUTN/EA19.1.0.0.0.ZUTN', use_readLines = TRUE)
# }

Run the code above in your browser using DataLab