diff --git a/NEWS.md b/NEWS.md index 2b5b226ab26fc6b0f103372880dede20702b2f7d..e07a37bc32117fbe68afedc0f08dd5c32f890807 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,9 +4,11 @@ providers (@fmgithub2017, #3 github). * New function `rdb_dimensions()` to request the list of the dimensions of the available datasets of the providers (@fmgithub2017, #3 github). +* New function `rdb_series()` to request the list of the series of + the available datasets of the providers (@fmgithub2017, #3 github). * Add a clearer error message to the function to_xts() in README (Martin Feldkircher, 20200326 email). -* Update vignette for `rdb_datasets()` and `rdb_dimensions()`. +* Update vignette for `rdb_datasets()`, `rdb_dimensions()` and `rdb_series()`. # rdbnomics 0.5.2 diff --git a/R/rdb_datasets.R b/R/rdb_datasets.R index bd34ccfd6e8d0d984767296e78e6f7bd8b60552b..21397cc3dd5de776cd7f20bec9348c79db0f195b 100644 --- a/R/rdb_datasets.R +++ b/R/rdb_datasets.R @@ -69,9 +69,9 @@ rdb_datasets <- function( # }, simplify = FALSE) # Additionals arguments - progress_bar = TRUE + progress_bar <- TRUE if (length(list(...)) > 0) { - tmp_progress_bar = list(...)$progress_bar + tmp_progress_bar <- list(...)$progress_bar if (!is.null(tmp_progress_bar)) { progress_bar <- tmp_progress_bar } diff --git a/R/rdb_dimensions.R b/R/rdb_dimensions.R index 385347db6eda66a2063d829b0cc94a36fade9ecc..2bb0c414f3d5a4781553bddeba658ebd7f74a3d2 100644 --- a/R/rdb_dimensions.R +++ b/R/rdb_dimensions.R @@ -71,9 +71,9 @@ rdb_dimensions <- function( ... ) { # Additionals arguments - progress_bar = TRUE + progress_bar <- TRUE if (length(list(...)) > 0) { - tmp_progress_bar = list(...)$progress_bar + tmp_progress_bar <- list(...)$progress_bar if (!is.null(tmp_progress_bar)) { progress_bar <- tmp_progress_bar } diff --git a/R/rdb_series.R b/R/rdb_series.R index 4732a3bad0cb6d3e563d90d2abc150bc7111f7d2..2103cf9faf200185854c90a69ccfcdd7a1de94b2 100644 --- a/R/rdb_series.R +++ b/R/rdb_series.R @@ -75,24 +75,33 @@ rdb_series <- function( ... ) { # Additionals arguments - progress_bar = TRUE + progress_bar <- TRUE if (length(list(...)) > 0) { - tmp_progress_bar = list(...)$progress_bar + tmp_progress_bar <- list(...)$progress_bar if (!is.null(tmp_progress_bar)) { progress_bar <- tmp_progress_bar } } check_argument(progress_bar, "logical") - only_first_two = FALSE + only_first_two <- FALSE if (length(list(...)) > 0) { - tmp_only_first_two = list(...)$only_first_two + tmp_only_first_two <- list(...)$only_first_two if (!is.null(tmp_only_first_two)) { only_first_two <- tmp_only_first_two } } check_argument(only_first_two, "logical") + only_number_series <- FALSE + if (length(list(...)) > 0) { + tmp_only_number_series <- list(...)$only_number_series + if (!is.null(tmp_only_number_series)) { + only_number_series <- tmp_only_number_series + } + } + check_argument(only_number_series, "logical") + # All providers if (is.null(provider_code)) { provider_code <- rdb_providers( @@ -146,6 +155,10 @@ rdb_series <- function( limit <- DBlist$series$limit num_found <- DBlist$series$num_found + if (only_number_series) { + return(data.table(Number_of_series = num_found)) + } + if (verbose) { if (getOption("rdbnomics.progress_bar_series") & progress_bar) { cat("\n") diff --git a/R/sysdata.rda b/R/sysdata.rda index acd85d7cb81aeab479ab311bffecb9f4afb304c0..8ef293f2913bdd7889e9a058dfb3c0dee61f092a 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/README.md b/README.md index 9aafd7b2f2f825a28926b1ba5d1af396fa4206e8..7006bf525d8e5a1215ab29d1d55b1b5c7a919d6b 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,16 @@ provider, if you define `simplify = TRUE`, then the result will be a named list df_dimensions <- rdb_dimensions(provider_code = "IMF", dataset_code = "WEO", simplify = TRUE) ``` +## Fetch the number of series of available datasets of a provider +```r +# Example for the dataset WEOAGG of the IMF: +rdb_series(provider_code = "IMF", dataset_code = "WEOAGG", simplify = TRUE) +``` + +:warning: We ask the user to use this function parsimoniously because there are a huge amount +of series per dataset. Please only fetch for one dataset if you need it or +visit the website [https://db.nomics.world](https://db.nomics.world). + ## Proxy configuration or connection error `Could not resolve host` When using the function `rdb`, you may come across the following error: ```r diff --git a/vignettes/rdbnomics.Rmd b/vignettes/rdbnomics.Rmd index 88dfd18cc7a00604a61ab7b807090b027c5f85fe..2d8813cd08e9d5cb7175e6a5af2d747ed721333c 100644 --- a/vignettes/rdbnomics.Rmd +++ b/vignettes/rdbnomics.Rmd @@ -688,7 +688,7 @@ You can measure the vast extent of datasets gathered by [DBnomics](https://db.nomics.world) by downloading all the possible dimensions. To do this, you have to set the arguments `provider_code` and `dataset_code` to `NULL`. -Warning : it's relatively long to run and heavy to show so we display +<b><font color='red'>⚠</font></b> it's relatively long to run and heavy to show so we display the first 100. ```{r, eval = FALSE} options(rdbnomics.progress_bar_datasets = TRUE) @@ -726,6 +726,31 @@ rdbnomics:::rdbnomics_df022 %>% # rbindlist(idcol = "Provider") ``` +# Fetch the number of series of available datasets of a provider + +You can download the list of series, and especially their codes, of a dataset's +provider by using the function `rdb_series`. The result is a nested named list +with a `data.table` at the end of each branch. If you define `simplify = TRUE`, +then the result will be a named list `data.table` not a nested named list. +For example, for the **IMF** provider and the dataset **WEO**, the command is: +```{r, eval = FALSE} +rdb_series(provider_code = "IMF", dataset_code = "WEO", simplify = TRUE) +``` +```{r, eval = TRUE, echo = FALSE} +rdbnomics:::rdbnomics_df023 %>% + display_table() +``` + +<b><font color='red'>⚠</font></b> We ask the user to use this function parsimoniously because there are a huge amount +of series per dataset. Please only fetch for one dataset if you need it or +visit the website [https://db.nomics.world](https://db.nomics.world). +For example, for the **IMF** provider, the number of series is: +```{r, eval = TRUE, echo = FALSE} +rdbnomics:::rdbnomics_df024 %>% + .[order(-`Number of series`)] %>% + display_table() +``` + # Proxy configuration or connection error `Could not resolve host` When using the function `rdb`, you may come across the following error: