Commit 821bb165 authored by Sébastien Galais's avatar Sébastien Galais

Correct README, docs (curl_config, proxy), internal data (BOE)

parent 259f9ecb
Pipeline #87030 passed with stage
in 11 minutes and 8 seconds
......@@ -39,7 +39,7 @@
#' @param ... Arguments to be passed to \code{\link{rdb_by_api_link}}. These
#' arguments concern connection configuration. See \code{\link{rdb_by_api_link}}
#' for details.
#' @return A \code{data.frame} or a \code{data.table}.
#' @return A \code{data.table}.
#' @examples
#' \dontrun{
#' ## By ids
......
......@@ -14,19 +14,11 @@
#' 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}.
#' @param curl_config Curl_handle or named list (default \code{NULL}). If not
#' @param 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}. If it is a \code{curl_handle} object then it is considered to
#' be the argument \code{handle} of \code{curl_fetch_memory}. In the case of a
#' list, two cases are considered. If an element of the list is a \code{curl_handle}
#' object then the names of the object are the arguments names of
#' \code{curl_fetch_memory} (except \code{url} of course). It means that
#' \code{curl_config = h} is equivalent to
#' \code{curl_config = list(handle = h)}.
#' If none of the elements is a \code{curl_handle} object then a temporary
#' \code{curl_handle} object is created internally with options equal to
#' \code{curl_config}.\cr
#' \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
......@@ -38,7 +30,7 @@
#' 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.
#' @return A \code{data.frame} or a \code{data.table}.
#' @return A \code{data.table}.
#' @examples
#' \dontrun{
#' # Fetch two series from different datasets of different providers :
......
......@@ -3,7 +3,7 @@
#' \code{rdb_last_updates} downloads informations about the last updates from
#' \href{https://db.nomics.world/}{DBnomics}.
#'
#' By default, the function returns a \code{data.frame} (or a \code{data.table})
#' By default, the function returns a \code{data.table}
#' containing the last 100 updates from
#' \href{https://db.nomics.world/}{DBnomics} with additional informations.
#'
......@@ -13,29 +13,25 @@
#' 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}.
#' @param curl_config Curl_handle or named list (default \code{NULL}). If not
#' @param 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}. If it is a \code{curl_handle} object then it is considered to
#' be the argument \code{handle} of \code{curl_fetch_memory}. In the case of a
#' list, two cases are considered. If an element of the list is a \code{curl_handle}
#' object then the names of the object are the arguments names of
#' \code{curl_fetch_memory} (except \code{url} of course). It means that
#' \code{curl_config = h} is equivalent to
#' \code{curl_config = list(handle = h)}.
#' If none of the elments is a \code{curl_handle} object then a temporary
#' \code{curl_handle} object is created internally with options equal to
#' \code{curl_config}.\cr
#' \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}.
#' @return A \code{data.frame} or a \code{data.table}.
#' @return A \code{data.table}.
#' @examples
#' \dontrun{
#' rdb_last_updates()
#'
#' rdb_last_updates(all = TRUE)
#'
#' rdb_last_updates(use_readLines = TRUE)
#'
#' rdb_last_updates(curl_config = list(proxy = "<proxy>", proxyport = <port>))
#' }
#' @seealso \code{\link{rdb_providers}}
#' @export
......
......@@ -3,7 +3,7 @@
#' \code{rdb_providers} downloads the list of providers from
#' \href{https://db.nomics.world/}{DBnomics}.
#'
#' By default, the function returns a \code{data.frame} (or a \code{data.table})
#' By default, the function returns a \code{data.table}
#' containing the list of providers from
#' \href{https://db.nomics.world/}{DBnomics} with additional informations such as
#' the region, the website, etc.
......@@ -14,29 +14,25 @@
#' 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}.
#' @param curl_config Curl_handle or named list (default \code{NULL}). If not
#' @param 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}. If it is a \code{curl_handle} object then it is considered to
#' be the argument \code{handle} of \code{curl_fetch_memory}. In the case of a
#' list, two cases are considered. If an element of the list is a \code{curl_handle}
#' object then the names of the object are the arguments names of
#' \code{curl_fetch_memory} (except \code{url} of course). It means that
#' \code{curl_config = h} is equivalent to
#' \code{curl_config = list(handle = h)}.
#' If none of the elments is a \code{curl_handle} object then a temporary
#' \code{curl_handle} object is created internally with options equal to
#' \code{curl_config}.\cr
#' \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}.
#' @return A \code{data.frame}, a \code{data.table} or a vector.
#' @return A \code{data.table} or a vector.
#' @examples
#' \dontrun{
#' rdb_providers()
#'
#' rdb_providers(code = TRUE)
#'
#' rdb_providers(use_readLines = TRUE)
#'
#' rdb_providers(curl_config = list(proxy = "<proxy>", proxyport = <port>))
#' }
#' @seealso \code{\link{rdb_last_updates}}
#' @export
......
No preview for this file type
......@@ -105,10 +105,7 @@ To get round this situation, you have two possibilities:
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`. In that way:
- if the object is of class `curl_handle` then it is passed to the argument `handle` of the `curl_fetch_memory` function,
- if the object is a named list then the elements are passed to the connection (the `curl_handle` object created internally with `new_handle()`) with `handle_setopt()` before using `curl_fetch_memory`.
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 <a href="https://curl.haxx.se/libcurl/c/curl_easy_setopt.html" target="_blank">https://curl.haxx.se/libcurl/c/curl_easy_setopt.html</a>. Once they are chosen, you define the curl object as follows:
```r
......
......@@ -42,7 +42,7 @@ arguments concern connection configuration. See \code{\link{rdb_by_api_link}}
for details.}
}
\value{
A \code{data.frame} or a \code{data.table}.
A \code{data.table}.
}
\description{
\code{rdb} downloads data series from
......
......@@ -17,19 +17,11 @@ 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}{Curl_handle or named list (default \code{NULL}). If not
\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}. If it is a \code{curl_handle} object then it is considered to
be the argument \code{handle} of \code{curl_fetch_memory}. In the case of a
list, two cases are considered. If an element of the list is a \code{curl_handle}
object then the names of the object are the arguments names of
\code{curl_fetch_memory} (except \code{url} of course). It means that
\code{curl_config = h} is equivalent to
\code{curl_config = list(handle = h)}.
If none of the elements is a \code{curl_handle} object then a temporary
\code{curl_handle} object is created internally with options equal to
\code{curl_config}.\cr
\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
......@@ -44,7 +36,7 @@ and an element \code{parameters} which is a named list with elements \code{frequ
and \code{method} or a NULL.}
}
\value{
A \code{data.frame} or a \code{data.table}.
A \code{data.table}.
}
\description{
\code{rdb_by_api_link} downloads data series from
......
......@@ -17,33 +17,25 @@ 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}{Curl_handle or named list (default \code{NULL}). If not
\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}. If it is a \code{curl_handle} object then it is considered to
be the argument \code{handle} of \code{curl_fetch_memory}. In the case of a
list, two cases are considered. If an element of the list is a \code{curl_handle}
object then the names of the object are the arguments names of
\code{curl_fetch_memory} (except \code{url} of course). It means that
\code{curl_config = h} is equivalent to
\code{curl_config = list(handle = h)}.
If none of the elments is a \code{curl_handle} object then a temporary
\code{curl_handle} object is created internally with options equal to
\code{curl_config}.\cr
\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}.}
}
\value{
A \code{data.frame} or a \code{data.table}.
A \code{data.table}.
}
\description{
\code{rdb_last_updates} downloads informations about the last updates from
\href{https://db.nomics.world/}{DBnomics}.
}
\details{
By default, the function returns a \code{data.frame} (or a \code{data.table})
By default, the function returns a \code{data.table}
containing the last 100 updates from
\href{https://db.nomics.world/}{DBnomics} with additional informations.
}
......@@ -52,6 +44,10 @@ containing the last 100 updates from
rdb_last_updates()
rdb_last_updates(all = TRUE)
rdb_last_updates(use_readLines = TRUE)
rdb_last_updates(curl_config = list(proxy = "<proxy>", proxyport = <port>))
}
}
\seealso{
......
......@@ -17,33 +17,25 @@ 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}{Curl_handle or named list (default \code{NULL}). If not
\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}. If it is a \code{curl_handle} object then it is considered to
be the argument \code{handle} of \code{curl_fetch_memory}. In the case of a
list, two cases are considered. If an element of the list is a \code{curl_handle}
object then the names of the object are the arguments names of
\code{curl_fetch_memory} (except \code{url} of course). It means that
\code{curl_config = h} is equivalent to
\code{curl_config = list(handle = h)}.
If none of the elments is a \code{curl_handle} object then a temporary
\code{curl_handle} object is created internally with options equal to
\code{curl_config}.\cr
\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}.}
}
\value{
A \code{data.frame}, a \code{data.table} or a vector.
A \code{data.table} or a vector.
}
\description{
\code{rdb_providers} downloads the list of providers from
\href{https://db.nomics.world/}{DBnomics}.
}
\details{
By default, the function returns a \code{data.frame} (or a \code{data.table})
By default, the function returns a \code{data.table}
containing the list of providers from
\href{https://db.nomics.world/}{DBnomics} with additional informations such as
the region, the website, etc.
......@@ -53,6 +45,10 @@ the region, the website, etc.
rdb_providers()
rdb_providers(code = TRUE)
rdb_providers(use_readLines = TRUE)
rdb_providers(curl_config = list(proxy = "<proxy>", proxyport = <port>))
}
}
\seealso{
......
......@@ -38,7 +38,7 @@ h4.date { /* Header 4 - and the author and data headers use this too */
# DBnomics: the world's economic database
You can explore all the economic data from different providers by following the link [db.nomics.world](https://db.nomics.world)
(*N.B.: in the examples, data have already been retrieved on september 5<sup>th</sup> 2019*).
(*N.B.: in the examples, data have already been retrieved on september 10<sup>th</sup> 2019*).
[![](dbnomics001.png)](https://db.nomics.world)
......@@ -443,11 +443,11 @@ ggplot(df, aes(x = period, y = value, color = series_name)) +
On the cart page of the [DBnomics website](https://db.nomics.world), click on "*Copy API link*" and copy-paste it as an argument of the `rdb_by_api_link` function. Please note that when you update your cart, you have to copy this link again, because the link itself contains the ids of the series in the cart.
<center>
![](dbnomics004.png)
![](dbnomics005.png)
</center>
```{r, eval = FALSE}
df <- rdb_by_api_link("https://api.db.nomics.world/v22/series?series_ids=BOE%2F8745%2FLPMB23A%2CBOE%2F8745%2FLPMB26A&observations=1&format=json&align_periods=1") %>%
df <- rdb_by_api_link("https://api.db.nomics.world/v22/series?observations=1&series_ids=BOE/6008/RPMTDDC,BOE/6231/RPMTBVE") %>%
filter(!is.na(value))
```
```{r, eval = TRUE, echo = FALSE}
......@@ -462,7 +462,7 @@ df %<>%
function(y) {
paste0(
paste0(
strsplit(y, "approvals ")[[1]], collapse = "approvals\n"
strsplit(y, "institutions' ")[[1]], collapse = "institutions'\n"
),
"\n"
)
......@@ -501,10 +501,7 @@ To get round this situation, you have two options:
## 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`. In that way:
- if the object is of class `curl_handle` then it is passed to the argument `handle` of the `curl_fetch_memory` function,
- if the object is a named list then the elements are passed to the connection (the `curl_handle` object created internally with `new_handle()`) with `handle_setopt()` before using `curl_fetch_memory`.
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 <a href="https://curl.haxx.se/libcurl/c/curl_easy_setopt.html" target="_blank">https://curl.haxx.se/libcurl/c/curl_easy_setopt.html</a>. Once they are chosen, you define the curl object as follows:
```{r, eval = FALSE}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment