Commit 5ce7cb96 authored by Sébastien Galais's avatar Sébastien Galais

Small modifications (docs, vignette, README)

parent b9d3d139
Pipeline #89942 passed with stage
in 11 minutes and 38 seconds
No preview for this file type
......@@ -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 10<sup>th</sup> 2019*).
(*N.B.: in the examples, data have already been retrieved on september 23<sup>rd</sup> 2019*).
[![](dbnomics001.png)](https://db.nomics.world)
......@@ -67,7 +67,8 @@ library(rdbnomics)
reorder_cols <- function(x) {
cols <- c(
"provider_code", "dataset_code", "dataset_name", "series_code",
"series_name", "original_period", "period", "value", "@frequency"
"series_name", "original_period", "period", "original_value", "value",
"@frequency"
)
if ("unit" %in% colnames(x)) {
......@@ -98,12 +99,12 @@ scale_colour_discrete <- function(...) {
knitr::opts_chunk$set(dev.args = list(bg = "transparent"))
dbnomics <- function(legend_title = "Code") {
dbnomics <- function() {
list(
scale_x_date(expand = c(0, 0)),
scale_y_continuous(labels = function(x) { format(x, big.mark = " ") }),
xlab(""),
ylab(""),
guides(color = guide_legend(title = legend_title)),
theme_bw(),
theme(
legend.position = "bottom", legend.direction = "vertical",
......@@ -114,7 +115,7 @@ dbnomics <- function(legend_title = "Code") {
legend.title = element_blank()
),
annotate(
geom = "text", label = "DBnomics",
geom = "text", label = "DBnomics <https://db.nomics.world>",
x = structure(Inf, class = "Date"), y = -Inf,
hjust = 1.1, vjust = -0.4, col = "grey",
fontface = "italic"
......@@ -163,6 +164,7 @@ In such data.frame (data.table or tibble), you will always find at least nine co
- `series_name`
- `original_period` (character string)
- `period` (date of the first day of `original_period`)
- `original_value` (character string)
- `value`
- `@frequency` (harmonized frequency generated by DBnomics)
......@@ -180,7 +182,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_code)) +
geom_line(size = 2) +
geom_line(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -208,7 +211,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_code)) +
geom_line(size = 2) +
geom_line(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -231,7 +235,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_code)) +
geom_line(size = 2) +
geom_line(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -255,7 +260,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_code)) +
geom_step(size = 2) +
geom_step(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -284,7 +290,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_code)) +
geom_step(size = 2) +
geom_step(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -348,7 +355,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_code)) +
geom_line(size = 2) +
geom_line(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -374,7 +382,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_code)) +
geom_line(size = 2) +
geom_line(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -400,7 +409,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_name)) +
geom_line(size = 2) +
geom_line(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -435,7 +445,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_name)) +
geom_step(size = 2) +
geom_step(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -480,7 +491,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(df, aes(x = period, y = value, color = series_name)) +
geom_line(size = 2) +
geom_line(size = 1.2) +
geom_point(size = 2) +
scale_y_continuous(labels = function(x) { format(x, big.mark = " ") }) +
dbnomics()
```
......@@ -570,8 +582,7 @@ 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).
The *Time Series Editor* is usable via the web interface but you can call it directly from *R*.
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:
......@@ -632,7 +643,8 @@ df %>%
```{r, fig.align = 'center'}
ggplot(filter(df, !is.na(value)), aes(x = period, y = value, color = series_name)) +
geom_line(size = 1) +
geom_line(size = 1.2) +
geom_point(size = 2) +
dbnomics()
```
......@@ -644,12 +656,12 @@ We show the function `dbnomics()` as an information. It's not implemented in the
package.
```{r, eval = FALSE}
dbnomics <- function(legend_title = "Code") {
dbnomics <- function() {
list(
scale_x_date(expand = c(0, 0)),
scale_y_continuous(labels = function(x) { format(x, big.mark = " ") }),
xlab(""),
ylab(""),
guides(color = guide_legend(title = legend_title)),
theme_bw(),
theme(
legend.position = "bottom", legend.direction = "vertical",
......@@ -660,7 +672,7 @@ dbnomics <- function(legend_title = "Code") {
legend.title = element_blank()
),
annotate(
geom = "text", label = "DBnomics",
geom = "text", label = "DBnomics <https://db.nomics.world>",
x = structure(Inf, class = "Date"), y = -Inf,
hjust = 1.1, vjust = -0.4, col = "grey",
fontface = "italic"
......
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