rdbnomics/ 0000755 0001762 0000144 00000000000 13616610265 012240 5 ustar ligges users rdbnomics/NAMESPACE 0000644 0001762 0000144 00000000314 13616554211 013453 0 ustar ligges users # Generated by roxygen2: do not edit by hand
export(dbnomics)
export(rdb)
export(rdb_by_api_link)
export(rdb_last_updates)
export(rdb_providers)
import(curl)
import(data.table)
import(jsonlite)
rdbnomics/README.md 0000644 0001762 0000144 00000034366 13604427673 013541 0 ustar ligges users # rdbnomics
[](https://cran.r-project.org/package=rdbnomics)
[](https://git.nomics.world/dbnomics/rdbnomics/commits/master)
[](https://CRAN.R-project.org/package=rdbnomics)
## DBnomics R client
This package provides you access to DBnomics data series. DBnomics is an open-source project with the goal of aggregating the world's economic data in one location, free of charge to the public. DBnomics covers hundreds of millions of series from international and national institutions (Eurostat, World Bank, IMF, ...).
To use this package, you have to provide the codes of the provider, dataset and series you want. You can retrieve them directly on the website. You have access to the API through this link and the documentation is here.
DBnomics is hosted on its own gitlab platform. However, in order to install the package more easily, we created a mirror of this package on github.
To install `rdbnomics` from CRAN:
```r
install.packages("rdbnomics")
library(rdbnomics)
```
To install `rdbnomics` from github:
```r
remotes::install_github("dbnomics/rdbnomics", build_vignettes = TRUE, force = TRUE)
library(rdbnomics)
```
After installation, a vignette is available to the user:
```r
vignette("rdbnomics")
```
## Examples
### Fetch time series by `ids`:
```r
# 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/BOP/A.FR.BCA_BP6_EUR"))
```
In the event that you only use the argument `ids`, you can drop it and run:
```r
df <- rdb("AMECO/ZUTN/EA19.1.0.0.0.ZUTN")
```
### Fetch time series by `mask` :
```r
# Fetch one series from dataset 'Balance of Payments' (BOP) of IMF:
df1 <- rdb("IMF", "BOP", mask = "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")
```
In the event that you only use the arguments `provider_code`, `dataset_code` and `mask`, you can drop the name `mask` and run:
```r
df4 <- rdb("IMF", "BOP", "A.FR.BCA_BP6_EUR")
```
### Fetch time series by `dimensions`:
```r
# 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:
df3 <- rdb("WB", "DB", dimensions = list(country = c("DZ", "PE"), indicator = c("ENF.CONT.COEN.COST.ZS", "IC.REG.COST.PC.FE.ZS")))
# or
df3 <- rdb("WB", "DB", dimensions = '{"country": ["DZ", "PE"], "indicator": ["ENF.CONT.COEN.COST.ZS", "IC.REG.COST.PC.FE.ZS"]}')
```
### Fetch time series with a `query`:
```r
# Fetch one series from dataset 'WEO by countries' (WEO) of IMF provider:
df1 <- rdb("IMF", "WEO", query = "France current account balance percent")
# Fetch series from dataset 'WEO by countries' (WEO) of IMF provider:
df2 <- rdb("IMF", "WEO", query = "current account balance percent")
```
### Fetch one series from the dataset 'Doing Business' of WB provider with the link:
```r
df1 <- rdb(api_link = "https://api.db.nomics.world/v22/series/WB/DB?dimensions=%7B%22country%22%3A%5B%22FR%22%2C%22IT%22%2C%22ES%22%5D%7D&q=IC.REG.PROC.FE.NO&observations=1&format=json&align_periods=1&offset=0&facets=0")
```
In the event that you only use the argument `api_link`, you can drop the name and run:
```r
df1 <- rdb("https://api.db.nomics.world/v22/series/WB/DB?dimensions=%7B%22country%22%3A%5B%22FR%22%2C%22IT%22%2C%22ES%22%5D%7D&q=IC.REG.PROC.FE.NO&observations=1&format=json&align_periods=1&offset=0&facets=0")
```
## Proxy configuration or connection error `Could not resolve host`
When using the function `rdb`, you may come across the following error:
```r
Error in open.connection(con, "rb") :
Could not resolve host: api.db.nomics.world
```
To get round this situation, you have two possibilities:
1. configure **curl** to use a specific and authorized proxy.
2. use the default R internet connection i.e. the Internet Explorer proxy defined in *internet2.dll*.
### Configure **curl** to use a specific and authorized proxy
In **rdbnomics**, by default the function `curl_fetch_memory` (of the package **curl**) is used to fetch the data. If a specific proxy must be used, it is possible to define it permanently with the package option `rdbnomics.curl_config` or on the fly through the argument `curl_config`. Because the object is a named list, its elements are passed to the connection (the `curl_handle` object created internally with `new_handle()`) with `handle_setopt()` before using `curl_fetch_memory`.
To see the available parameters, run `names(curl_options())` in *R* or visit the website https://curl.haxx.se/libcurl/c/curl_easy_setopt.html. Once they are chosen, you define the curl object as follows:
```r
h <- list(
proxy = "",
proxyport = ,
proxyusername = "",
proxypassword = ""
)
```
#### Set the connection up for a session
The curl connection can be set up for a session by modifying the following package option:
```r
options(rdbnomics.curl_config = h)
```
When fetching the data, the following command is executed:
```r
hndl <- curl::new_handle()
curl::handle_setopt(hndl, .list = getOption("rdbnomics.curl_config"))
curl::curl_fetch_memory(url = <...>, handle = hndl)
```
After configuration, just use the standard functions of **rdbnomics** e.g.:
```r
df1 <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN")
```
This option of the package can be disabled with:
```r
options(rdbnomics.curl = NULL)
```
#### Use the connection only for a function call
If a complete configuration is not needed but just an "on the fly" execution, then use the argument `curl_config` of the function `rdb`:
```r
df1 <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN", curl_config = h)
```
### Use the default R internet connection
To retrieve the data with the default R internet connection, **rdbnomics** will use the base function `readLines`.
#### Set the connection up for a session
To activate this feature for a session, you need to enable an option of the package:
```r
options(rdbnomics.use_readLines = TRUE)
```
And then use the standard function as follows:
```r
df1 <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN")
```
This configuration can be disabled with:
```r
options(rdbnomics.use_readLines = FALSE)
```
#### Use the connection only for a function call
If you just want to do it once, you may use the argument `use_readLines` of the function `rdb`:
```r
df1 <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN", use_readLines = TRUE)
```
## Transform time series with filters
The **rdbnomics** package can interact with the *Time Series Editor* of DBnomics to transform time series by applying filters to them.
Available filters are listed on the filters page [https://editor.nomics.world/filters](https://editor.nomics.world/filters).
Here is an example of how to proceed to interpolate two annual time series with a monthly frequency, using a spline interpolation:
```r
filters <- list(
code = "interpolate",
parameters = list(frequency = "monthly", method = "spline")
)
df <- rdb(
ids = c("AMECO/ZUTN/EA19.1.0.0.0.ZUTN", "AMECO/ZUTN/DNK.1.0.0.0.ZUTN"),
filters = filters
)
```
If you want to apply more than one filter, the `filters` argument will be a list of valid filters:
```r
filters <- list(
list(
code = "interpolate",
parameters = list(frequency = "monthly", method = "spline")
),
list(
code = "aggregate",
parameters = list(frequency = "bi-annual", method = "end_of_period")
)
)
df <- rdb(
ids = c("AMECO/ZUTN/EA19.1.0.0.0.ZUTN", "AMECO/ZUTN/DNK.1.0.0.0.ZUTN"),
filters = filters
)
```
The `data.table` columns change a little bit when filters are used. There are two new columns:
- `period_middle_day`: the middle day of `original_period` (can be useful when you compare graphically interpolated series and original ones).
- `filtered` (boolean): `TRUE` if the series is filtered, `FALSE` otherwise.
The content of two columns are modified:
- `series_code`: same as before for original series, but the suffix `_filtered` is added for filtered series.
- `series_name`: same as before for original series, but the suffix ` (filtered)` is added for filtered series.
## Transform the `data.table` object into a `xts` object
For some analysis, it is more convenient to have a `xts` object instead of a `data.table` object. To transform
it, you can use the following functions:
```r
library(xts)
library(data.table)
library(rdbnomics)
to_xts <- function(
x,
needed_columns = c("period", "series_code", "series_name", "value"),
series_columns = c("series_code", "series_name")
) {
if (is.null(x)) {
return(NULL)
}
all_cols <- length(setdiff(needed_columns, colnames(x))) != 0
if (all_cols) {
stop(
paste0(
"To export as a xts object, some columns are missing. Needed columns ",
"are \u0022", paste0(needed_columns, collapse = "\u0022, \u0022"),
"\u0022"
),
call. = FALSE
)
}
x <- x[, .SD, .SDcols = needed_columns]
data.table::setcolorder(x, needed_columns)
attr_names <- NULL
if (!is.null(series_columns)) {
attr_names <- unique(x[, .SD, .SDcols = series_columns])
}
if (nrow(x) > 0) {
x <- data.table::dcast.data.table(
x, period ~ series_code,
value.var = "value"
)
} else {
orig <- Sys.Date() - as.numeric(Sys.Date())
x <- data.table(
period = as.Date(numeric(), origin = orig),
no_code = numeric()
)
}
x <- data.table::as.xts.data.table(x)
xts::xtsAttributes(x) <- list(codename = attr_names)
x
}
rdb("IMF", "BOP", mask = "A.FR+ES.BCA_BP6_EUR")
#> ... original_value period provider_code REF_AREA Reference Area series_code ...
#> 1: NA 1940-01-01 IMF ES Spain A.ES.BCA_BP6_EUR
#> 2: NA 1941-01-01 IMF ES Spain A.ES.BCA_BP6_EUR
#> --- ... ... ... ... ... ...
#> 159: -15136.8 2018-01-01 IMF FR France A.FR.BCA_BP6_EUR
#> 160: NA 2019-01-01 IMF FR France A.FR.BCA_BP6_EUR
to_xts(rdb("IMF", "BOP", mask = "A.FR+ES.BCA_BP6_EUR"))
#> A.ES.BCA_BP6_EUR A.FR.BCA_BP6_EUR
#> 1940-01-01 NA NA
#> 1941-01-01 NA NA
#> 1942-01-01 NA NA
#> ... ... ...
#> 2017-01-01 31086 -16397.700
#> 2018-01-01 23283 -15136.800
#> 2019-01-01 NA NA
```
In the `xts` object, the series codes are used as column names. If you prefer
the series names (or apply a function to them), you can utilize the function:
```r
library(magrittr)
rdb_rename_xts <- function(x, fun = NULL, ...) {
nm <- xts::xtsAttributes(x)$codename
cols <- nm$series_name[match(names(x), nm$series_code)]
if (is.null(fun)) {
names(x) <- cols
} else {
names(x) <- sapply(X = cols, FUN = fun, ..., USE.NAMES = FALSE)
}
x
}
rdb("IMF", "BOP", mask = "A.FR+ES.BCA_BP6_EUR") %>%
to_xts() %>%
rdb_rename_xts()
#> Annual – Spain – Current Account, Total, Net, Euros Annual – France – Current Account, Total, Net, Euros
#> 1940-01-01 NA NA
#> 1941-01-01 NA NA
#> 1942-01-01 NA NA
#> ... ... ...
#> 2017-01-01 31086 -16397.700
#> 2018-01-01 23283 -15136.800
#> 2019-01-01 NA NA
rdb("IMF", "BOP", mask = "A.FR+ES.BCA_BP6_EUR") %>%
to_xts() %>%
rdb_rename_xts(stringr::word, start = 3)
#> Spain France
#> 1940-01-01 NA NA
#> 1941-01-01 NA NA
#> 1942-01-01 NA NA
#> ... ... ...
#> 2017-01-01 31086 -16397.700
#> 2018-01-01 23283 -15136.800
#> 2019-01-01 NA NA
```
## P.S.
Visit https://db.nomics.world/ !
rdbnomics/man/ 0000755 0001762 0000144 00000000000 13616545645 013024 5 ustar ligges users rdbnomics/man/rdbnomics.Rd 0000644 0001762 0000144 00000000352 13616554211 015260 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rdbnomics.R
\docType{package}
\name{rdbnomics}
\alias{rdbnomics}
\title{Package rdbnomics}
\description{
DBnomics R client ().
}
rdbnomics/man/rdb_by_api_link.Rd 0000644 0001762 0000144 00000012033 13604436273 016412 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rdb_by_api_link.R
\name{rdb_by_api_link}
\alias{rdb_by_api_link}
\title{Download DBnomics data using API link (deprecated).}
\usage{
rdb_by_api_link(
api_link,
use_readLines = getOption("rdbnomics.use_readLines"),
curl_config = getOption("rdbnomics.curl_config"),
filters = getOption("rdbnomics.filters")
)
}
\arguments{
\item{api_link}{Character string. DBnomics API link of the search.}
\item{use_readLines}{Logical (default \code{FALSE}). If \code{TRUE}, then
the data are requested and read with the base function \code{readLines} i.e.
through the default R internet connection. This can be used to get round the
error \code{Could not resolve host: api.db.nomics.world}.}
\item{curl_config}{Named list (default \code{NULL}). If not
\code{NULL}, it is used to configure a proxy connection. This
configuration is passed to the function \code{curl_fetch_memory} of the package
\pkg{curl}. A temporary \code{curl_handle} object is created internally
with arguments equal to the provided list in \code{curl_config}.\cr
For \code{curl_fetch_memory} arguments see \code{\link[curl]{curl_fetch}}.
For available curl options see \code{\link[curl]{curl_options}},
\code{names(curl_options())} and
\href{https://curl.haxx.se/libcurl/c/curl_easy_setopt.html}{libcurl}.}
\item{filters}{List (default \code{NULL}). This argument must be a named
list for one filter because the function \code{toJSON} of the package \pkg{jsonlite}
is used before sending the request to the server. For multiple filters,
you have to provide a list of valid filters (see examples).\cr
A valid filter is a named list with an element \code{code} which is a character string,
and an element \code{parameters} which is a named list with elements \code{frequency}
and \code{method} or a NULL.}
}
\value{
A \code{data.table}.
}
\description{
\code{rdb_by_api_link} downloads data series from
\href{https://db.nomics.world/}{DBnomics}.
}
\details{
This function gives you access to hundreds of millions data series from
\href{https://api.db.nomics.world/}{DBnomics API} (documentation about
the API can be found \href{https://api.db.nomics.world/v22/apidocs}{here}).
The API link is given on the
\href{https://db.nomics.world/}{DBnomics website}.
}
\examples{
\dontrun{
# Fetch two series from different datasets of different providers :
df1 <- rdb_by_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_by_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"
)
)
## Use a specific proxy to fetch the data
# Fetch one series from the dataset 'Doing Business' of WB provider :
h <- list(
proxy = "",
proxyport = ,
proxyusername = "",
proxypassword = ""
)
options(rdbnomics.curl_config = h)
df2 <- rdb_by_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 to use once
df2 <- rdb_by_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"
),
curl_config = h
)
## Use R default connection to avoid a proxy failure (in some cases)
# Fetch one series from the dataset 'Doing Business' of WB provider :
options(rdbnomics.use_readLines = TRUE)
df2 <- rdb_by_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 to use once
df2 <- rdb_by_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"
),
use_readLines = TRUE
)
## Apply filter(s) to the series
# One filter
df3 <- rdb_by_api_link(
"https://api.db.nomics.world/v22/series/IMF/WEO/ABW.BCA?observations=1",
filters = list(
code = "interpolate",
parameters = list(frequency = "daily", method = "spline")
)
)
# Two filters
df3 <- rdb_by_api_link(
"https://api.db.nomics.world/v22/series/IMF/WEO/ABW.BCA?observations=1",
filters = list(
list(
code = "interpolate",
parameters = list(frequency = "quarterly", method = "spline")
),
list(
code = "aggregate",
parameters = list(frequency = "annual", method = "average")
)
)
)
}
}
\seealso{
\code{\link{rdb}}
}
\author{
Sebastien Galais
}
rdbnomics/man/rdb.Rd 0000644 0001762 0000144 00000021060 13604436273 014052 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rdb.R
\name{rdb}
\alias{rdb}
\title{Download DBnomics data.}
\usage{
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"),
...
)
}
\arguments{
\item{provider_code}{Character string (default \code{NULL}). DBnomics code
of the provider.}
\item{dataset_code}{Character string (default \code{NULL}). DBnomics code
of the dataset.}
\item{ids}{Character string (default \code{NULL}). DBnomics code of one or
several series.}
\item{dimensions}{List or character string (single quoted) (default \code{NULL}).
DBnomics code of one or several dimensions in the specified provider and dataset.
If it is a named list, then the function \code{toJSON} (from the
package \pkg{jsonlite}) is applied to generate the json object.}
\item{mask}{Character string (default \code{NULL}). DBnomics code of one or
several masks in the specified provider and dataset.}
\item{query}{Character string (default \code{NULL}). A query to
filter/select series from a provider's dataset.}
\item{api_link}{Character string. DBnomics API link of the search. It should
starts with \code{http://} or \code{https://}.}
\item{filters}{List (default \code{NULL}). This argument must be a named
list for one filter because the function \code{toJSON} of the package \pkg{jsonlite}
is used before sending the request to the server. For multiple filters,
you have to provide a list of valid filters (see examples).\cr
A valid filter is a named list with an element \code{code} which is a character string,
and an element \code{parameters} which is a named list with elements \code{frequency}
and \code{method} or a NULL.}
\item{use_readLines}{Logical (default \code{FALSE}). If \code{TRUE}, then
the data are requested and read with the base function \code{readLines} i.e.
through the default R internet connection. This can be used to get round the
error \code{Could not resolve host: api.db.nomics.world}.}
\item{curl_config}{Named list (default \code{NULL}). If not
\code{NULL}, it is used to configure a proxy connection. This
configuration is passed to the function \code{curl_fetch_memory} of the package
\pkg{curl}. A temporary \code{curl_handle} object is created internally
with arguments equal to the provided list in \code{curl_config}.\cr
For \code{curl_fetch_memory} arguments see \code{\link[curl]{curl_fetch}}.
For available curl options see \code{\link[curl]{curl_options}},
\code{names(curl_options())} and
\href{https://curl.haxx.se/libcurl/c/curl_easy_setopt.html}{libcurl}.}
\item{verbose}{Logical (default \code{FALSE}). Show warnings of the function.}
\item{...}{Arguments to be passed to the internal function \code{.rdb}.}
}
\value{
A \code{data.table}.
}
\description{
\code{rdb} downloads data series from
\href{https://db.nomics.world/}{DBnomics} using shortcuts like \code{ids},
\code{dimensions}, \code{mask}, \code{query} or using an \code{api_link}.
}
\details{
This function gives you access to hundreds of millions data series from
\href{https://api.db.nomics.world/}{DBnomics API} (documentation about
the API can be found \href{https://api.db.nomics.world/v22/apidocs}{here}).
The code of each series is given on the
\href{https://db.nomics.world/}{DBnomics website}. \cr\cr
In the event that only the argument \code{ids} is provided (and those in the
ellipsis \code{...}), the argument name can be dropped. The character string
vector is directly passed to \code{ids}. \cr
If only the argument \code{api_link} is provided (and those in the
ellipsis \code{...}), then the argument name can be dropped. The character string
vector is directly passed to \code{api_link}. \cr
In the same way, if only \code{provider_code}, \code{dataset_code} and
\code{mask} are provided then the arguments names can be dropped. The
last character string is automatically passed to \code{mask}.
}
\examples{
\dontrun{
## 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' (WEO) from IMF :
df1 <- rdb("IMF", "WEO", query = "France current account balance percent")
# Fetch series from dataset 'WEO by countries' (WEO) from IMF :
df2 <- rdb("IMF", "WEO", 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 = "",
proxyport = ,
proxyusername = "",
proxypassword = ""
)
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/ABW.BCA", "IMF/WEO/ABW.BCA_NGDPD"),
filters = list(
code = "interpolate",
parameters = list(frequency = "daily", method = "spline")
)
)
# Two filters
df1 <- rdb(
ids = c("IMF/WEO/ABW.BCA", "IMF/WEO/ABW.BCA_NGDPD"),
filters = list(
list(
code = "interpolate",
parameters = list(frequency = "quarterly", method = "spline")
),
list(
code = "aggregate",
parameters = list(frequency = "annual", method = "average")
)
)
)
}
}
\author{
Sebastien Galais
}
rdbnomics/man/figures/ 0000755 0001762 0000144 00000000000 13616545645 014470 5 ustar ligges users rdbnomics/man/figures/logo.png 0000644 0001762 0000144 00000075440 13371134545 016137 0 ustar ligges users PNG
IHDR sRGB gAMA a pHYs &? zIDATx^kՙ?/&fb3q]TA\;(A@䦀"((" (>\џcTbjRIa̔5J%T*Ij|_uڬ{g_ߪOW^g=W*zlLSs[G?3Rt̔w:ɜ^ |?DU;RZRI8cesb+3&@J`\Xλʜ6]eZL3SA칀IB:'yl*1!iZ&݈W|Zr?UZʔZMIjt̻|e! jșt"E4l2h9cWzWz%pCL.ؗ$=\DΜ-5 fF-VŶA_A#<06&;&=G'˜FcHLpCmͦdl{͘ņhkٿA3g3}vۘ=c,6lG͜?mLvM\0BFo^SfX3g~
K`+27|<ɚ7n Fn;[NϻvlدM=}e`Ǘ_fG:ͶH9kq帿fQw'D?306t=ImÎ~'?o2J%|)MzxFΜ2վ"e^af^ikmC3 qJVLeZI&jeWpi-`Lң=XpeZȤUfy?%#œ=70I^\3{)ISLTJTg*$3ysqf=s;qt§#g&S
iNS]8]dpDƥC2TJTҸ3IH^IDƵIR|0W`WlD{x"V&݃kFܑ3I2Llxxsb$Nڝҁ3W0s
3W0sJ̹ap'}G2W.3v7|hg_Ȇueۃ[s6-g後t촗M{߭!7=n65˰3FPi,m ~bqDܦd ˜
*茀`q_hlŕX
ٗ a^66`=+%3g_zȿazyI7ޡ_`or
cm8so_Wxmm&d
79Glx3z:7m{mNG_7G<һWw7J,(Ǟ{YV!j;¬ڼu\+͝+X Rfr""=*&{f
6]&)~h#NTMl:I^2r#N&Mrґ{")!I`o,K!gr0tIy qI`Օ/lVBg*(7ARwwsj+SAIp3Qզ2^'PiAx-pg*(7nO2<;1A_n&&.ljQn/ NuU*u:yc9Bh@bH{5
oKǩ+_Ԣѕi]*H@:7^4ɣ\I7w&T.`|rHWKHiLҔA]ʓnh ewƥwe)ږx eR9bxx\p+eTFX;cugRBDBxt5'v #ѹv}
2gVc"EẂrN@ǭS-$EJǭS-$EJǭS-$EJǭS-$EJǭS-$EJǭS-$EJǭS-$EJǭS-$EJǭS-$EJǭS-$EZ.R\v
w[=EYܣR:0RZAR"U6nj)-`]~A"]k"Upº۰n}nwݰkqx-V~7<ea܃BRa+"Hqr%.p>
ߐ-ASgv_1`ce L{P0BΖC%En j)-`Tqvw2Hq2|X=%ZºJ܊ VnYj)-`:u`܃HIu`܃HIu`܃lDv oKw_
<2 O;FMR8M˳6ۣցrB$Hm/a,Y^g̛y_I7|WU3ћ_Suc]I}|<_knk`_٠?|}ZCW:/{uX,ȇæo2Zǂ~z{ }y~ąJM.}=<,iūv |Q]6g?L{#;?{Co ?whI7omFbIO`zL=r[x'2}=# VK
}>|T}Uz߬]Q(8=Sfd07_rg])s_X!{y$E8r1$:RPNGCRϸv9w)'}$1HͿI RZZbm-qe{ucVoI;|# j;-BF&L@x-^c`_؋'N{l5Sd`BL)W.[I~"[L
xTS0 ~`NO%JV5,cw*Jqp1*J >]!|]`:J(UNE739oLQT:p;bɭ,,mP"U)IϺBTR/~s8UmI9׀OMTTڊ3EB:%]mVrLR<uSQIH*O=!VJTTATR&D\:G?NCo
S*$XC&=dD
m/ͼM/QAI,pFJ0ITW;¬6RZZ2Io>SX n(wxAѳ&+!0C*ZmԸ2
BUQ&].eT*zAʏ^U̝-D%,ey;xA^)ڗHʀFCwM?:|ֻXJU3ب%jnʹuj&XZP&