Description Usage Arguments Details Value Author(s) Examples
rdb
downloads data series from
DBnomics using shortcuts like ids
,
dimensions
, mask
, query
or using an api_link
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | rdb(
provider_code = NULL,
dataset_code = NULL,
ids = NULL,
dimensions = NULL,
mask = NULL,
query = NULL,
api_link = NULL,
filters = getOption("rdbnomics.filters"),
use_readLines = getOption("rdbnomics.use_readLines"),
curl_config = getOption("rdbnomics.curl_config"),
verbose = getOption("rdbnomics.verbose_warning"),
...
)
|
provider_code |
Character string (default |
dataset_code |
Character string (default |
ids |
Character string (default |
dimensions |
List or character string (single quoted) (default |
mask |
Character string (default |
query |
Character string (default |
api_link |
Character string. DBnomics API link of the search. It should
starts with |
filters |
List (default |
use_readLines |
Logical (default |
curl_config |
Named list (default |
verbose |
Logical (default |
... |
Arguments to be passed to the internal function |
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.
In the event that only the argument ids
is provided (and those in the
ellipsis ...
), the argument name can be dropped. The character string
vector is directly passed to ids
.
If only the argument api_link
is provided (and those in the
ellipsis ...
), then the argument name can be dropped. The character string
vector is directly passed to api_link
.
In the same way, if only provider_code
, dataset_code
and
mask
are provided then the arguments names can be dropped. The
last character string is automatically passed to mask
.
A data.table
.
Sebastien Galais
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | ## 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")
# or when no argument names are given (provider_code -> ids)
df1 <- rdb("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/BOP/A.FR.BCA_BP6_EUR"))
## By dimensions
# Fetch one value of one dimension from dataset 'Unemployment rate' (ZUTN) of AMECO provider:
df1 <- rdb("AMECO", "ZUTN", dimensions = list(geo = "ea12"))
# or
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 = list(geo = c("ea12", "dnk")))
# or
df2 <- rdb("AMECO", "ZUTN", dimensions = '{"geo":["ea12","dnk"]}')
# Fetch several values of several dimensions from dataset 'Doing business' (DB) of World Bank:
dim <- list(
country = c("DZ", "PE"),
indicator = c("ENF.CONT.COEN.COST.ZS", "IC.REG.COST.PC.FE.ZS")
)
df3 <- rdb("WB", "DB", dimensions = dim)
# or
dim <- paste0(
'{"country":["DZ","PE"],',
'"indicator":["ENF.CONT.COEN.COST.ZS","IC.REG.COST.PC.FE.ZS"]}'
)
df3 <- rdb("WB", "DB", dimensions = dim)
## By mask
# Fetch one series from dataset 'Balance of Payments' (BOP) of IMF:
df1 <- rdb("IMF", "BOP", mask = "A.FR.BCA_BP6_EUR")
# or when no argument names are given except provider_code and dataset_code (ids -> mask)
df1 <- rdb("IMF", "BOP", "A.FR.BCA_BP6_EUR")
# Fetch two series from dataset 'Balance of Payments' (BOP) of IMF:
df2 <- rdb("IMF", "BOP", mask = "A.FR+ES.BCA_BP6_EUR")
# Fetch all series along one dimension from dataset 'Balance of Payments' (BOP) of IMF:
df3 <- rdb("IMF", "BOP", mask = "A..BCA_BP6_EUR")
# Fetch series along multiple dimensions from dataset 'Balance of Payments' (BOP) of IMF:
df4 <- rdb("IMF", "BOP", mask = "A.FR.BCA_BP6_EUR+IA_BP6_EUR")
## By query
# Fetch one series from dataset 'WEO by countries (2019-10 release)' (WEO:2019-10) from IMF :
df1 <- rdb("IMF", "WEO:2019-10", query = "France current account balance percent")
# Fetch series from dataset 'WEO by countries (2019-10 release)' (WEO:2019-10) from IMF :
df2 <- rdb("IMF", "WEO:2019-10", query = "current account balance percent")
## By api_link
# Fetch two series from different datasets of different providers :
df1 <- rdb(
api_link = paste0(
"https://api.db.nomics.world/v22/",
"series?observations=1&series_ids=AMECO/ZUTN/EA19.1.0.0.0.ZUTN,IMF/CPI/A.AT.PCPIT_IX"
)
)
# Fetch one series from the dataset 'Doing Business' of WB provider :
df2 <- rdb(
api_link = paste0(
"https://api.db.nomics.world/v22/series/WB/DB?dimensions=%7B%22",
"indicator%22%3A%5B%22IC.REG.PROC.FE.NO%22%5D%7D&q=Doing%20Business",
"&observations=1&format=json&align_periods=1&offset=0&facets=0"
)
)
# or when no argument names are given (provider_code -> api_link)
df1 <- rdb(
paste0(
"https://api.db.nomics.world/v22/",
"series?observations=1&series_ids=AMECO/ZUTN/EA19.1.0.0.0.ZUTN,IMF/CPI/A.AT.PCPIT_IX"
)
)
## Use a specific proxy to fetch the data
# Fetch one series from dataset 'Unemployment rate' (ZUTN) of AMECO provider :
h <- list(
proxy = "<proxy>",
proxyport = <port>,
proxyusername = "<username>",
proxypassword = "<password>"
)
options(rdbnomics.curl_config = h)
df1 <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN")
# or to use once
options(rdbnomics.curl_config = NULL)
df1 <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN", curl_config = h)
## Use R default connection to avoid a proxy failure (in some cases)
# 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 to use once
df1 <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN", use_readLines = TRUE)
## Apply filter(s) to the series
# One filter
df1 <- rdb(
ids = c("IMF/WEO:2019-10/ABW.BCA.us_dollars", "IMF/WEO:2019-10/ABW.BCA_NGDPD.pcent_gdp"),
filters = list(
code = "interpolate",
parameters = list(frequency = "daily", method = "spline")
)
)
# Two filters
df1 <- rdb(
ids = c("IMF/WEO:2019-10/ABW.BCA.us_dollars", "IMF/WEO:2019-10/ABW.BCA_NGDPD.pcent_gdp"),
filters = list(
list(
code = "interpolate",
parameters = list(frequency = "quarterly", method = "spline")
),
list(
code = "aggregate",
parameters = list(frequency = "annual", method = "average")
)
)
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.