From 203150b0f2819c9818ca439fe432e8a81826a209 Mon Sep 17 00:00:00 2001 From: Guillaume Lombardo Date: Wed, 5 May 2021 23:32:47 +0200 Subject: [PATCH] change dependencies from httr, plyr to curl, purrr, dplyr and propose minor correction to readme * the dependencies from httr are moved to curl. * the signature of function using httr are changed to add a ... argument to be passed to curl::handle_setopt() (make proxy management easier) * propose a readme with shoter output --- .gitignore | 1 + DESCRIPTION | 15 +- NAMESPACE | 3 - R/IMFData.R | 174 +++++--- README.Rmd | 36 +- README.md | 558 ++++++------------------ docs/404.html | 145 ++++++ docs/LICENSE-text.html | 147 +++++++ docs/authors.html | 144 ++++++ docs/bootstrap-toc.css | 60 +++ docs/bootstrap-toc.js | 159 +++++++ docs/docsearch.css | 148 +++++++ docs/docsearch.js | 85 ++++ docs/index.html | 316 ++++++++++++++ docs/link.svg | 12 + docs/pkgdown.css | 367 ++++++++++++++++ docs/pkgdown.js | 108 +++++ docs/pkgdown.yml | 6 + docs/reference/CodeSearch.html | 197 +++++++++ docs/reference/CompactDataMethod.html | 276 ++++++++++++ docs/reference/DataStructureMethod.html | 182 ++++++++ docs/reference/DataflowMethod.html | 176 ++++++++ docs/reference/Rplot001.png | Bin 0 -> 1011 bytes docs/reference/index.html | 188 ++++++++ man/CodeSearch.Rd | 12 +- man/CompactDataMethod.Rd | 20 +- man/DataStructureMethod.Rd | 7 +- man/DataflowMethod.Rd | 9 +- 28 files changed, 3014 insertions(+), 537 deletions(-) create mode 100644 docs/404.html create mode 100644 docs/LICENSE-text.html create mode 100644 docs/authors.html create mode 100644 docs/bootstrap-toc.css create mode 100644 docs/bootstrap-toc.js create mode 100644 docs/docsearch.css create mode 100644 docs/docsearch.js create mode 100644 docs/index.html create mode 100644 docs/link.svg create mode 100644 docs/pkgdown.css create mode 100644 docs/pkgdown.js create mode 100644 docs/pkgdown.yml create mode 100644 docs/reference/CodeSearch.html create mode 100644 docs/reference/CompactDataMethod.html create mode 100644 docs/reference/DataStructureMethod.html create mode 100644 docs/reference/DataflowMethod.html create mode 100644 docs/reference/Rplot001.png create mode 100644 docs/reference/index.html diff --git a/.gitignore b/.gitignore index 886732b..9e8ec76 100755 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ vignettes/*.pdf *.utf8.md *.knit.md .Rproj.user +inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index 6cda838..84ebe4e 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,19 +1,24 @@ Package: IMFData Type: Package Title: R Interface for International Monetary Fund(IMF) Data API -Version: 0.2.0 -Date: 2016-10-16 +Version: 0.3.0 +Date: 2021-05-05 Authors@R: person("Ming-Jer", "Lee", email = "mingjerli@gmail.com", role = c("aut", "cre")) Depends: R (>= 3.1.0) Imports: - httr, + dplyr, + curl, jsonlite, - plyr + purrr Description: Search, extract and formulate IMF's datasets. License: MIT + file LICENSE LazyData: TRUE KeepSource: TRUE URL: https://github.com/mingjerli/IMFData -RoxygenNote: 5.0.1 +RoxygenNote: 7.1.1 +Suggests: + rmarkdown, + knitr +VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index 13a7e95..4084ec7 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,6 +4,3 @@ export(CodeSearch) export(CompactDataMethod) export(DataStructureMethod) export(DataflowMethod) -import(httr) -import(jsonlite) -import(plyr) diff --git a/R/IMFData.R b/R/IMFData.R index 528e1f2..cd88cef 100755 --- a/R/IMFData.R +++ b/R/IMFData.R @@ -6,6 +6,8 @@ #' @description \code{DataflowMethod} returns a data frame with availble #' datasets #' +#' @param ... parametres to pass to a curl handle (`?curl::handle_setopt`). +#' #' @return \code{DataflowMethod} returns a data frame object to describe #' available datasets from IMF data API. This data frame includes the following #' two columns: @@ -14,18 +16,23 @@ #' DatabaseText - Database description #' #' @examples -#' \donttest{ +#' \dontrun{ #' availableDB <- DataflowMethod() #' availableDB #' availableDB$DatabaseID[1] #' } -#' @import httr -#' @import jsonlite +#' #' @export -DataflowMethod <- function(){ - r <- httr::GET('http://dataservices.imf.org/REST/SDMX_JSON.svc/Dataflow', httr::add_headers('user-agent' = '')) - r.parsed <- jsonlite::fromJSON(httr::content(r, "text")) +DataflowMethod <- function(...){ + h <- curl::new_handle() + h <- curl::handle_setopt(h, ...) + + r <- curl::curl_fetch_memory(url = 'http://dataservices.imf.org/REST/SDMX_JSON.svc/Dataflow', handle = h) + is_json <- log_query(r) + if (is_json[[1]]) stop(is_json[[2]]) + r.parsed <- jsonlite::fromJSON(rawToChar(r$content)) + available.datasets <- r.parsed$Structure$Dataflows$Dataflow available.datasets.id <- available.datasets$KeyFamilyRef$KeyFamilyID available.datasets.text <- available.datasets$Name$`#text` @@ -34,6 +41,7 @@ DataflowMethod <- function(){ DatabaseText = available.datasets.text, stringsAsFactors = FALSE ) + return(available.db) } @@ -45,6 +53,7 @@ DataflowMethod <- function(){ #' #' @param databaseID string. Database ID of the dataset. Obtained from \code{DataflowMethod}. #' @param checkquery logical. If true, it will check the database ID is available or not. +#' @param ... parametres to pass to a curl handle (`?curl::handle_setopt`). #' #' @return \code{DataStructureMethod} returns a list of data frame to describe available dimensions in the dataset. #' The name of the list is the dimension name. @@ -54,41 +63,42 @@ DataflowMethod <- function(){ #' CodeText - dimension description. #' #' @examples -#' \donttest{ +#' \dontrun{ #' available.codes <- DataStructureMethod('IFS') #' names(available.codes) #' available.codes[[1]]#' #' } #' -#' @import httr -#' @import jsonlite -#' @import plyr #' @export -DataStructureMethod <- function(databaseID, checkquery = FALSE){ - # return a list with all dimension and legitimate values of each diemnsion - if(checkquery){ - available.datasets <- DataflowMethod()$DatabaseID - if (!is.element(databaseID, available.datasets)){ +DataStructureMethod <- function(databaseID, checkquery = FALSE, ...){ + # return a list with all dimension and legitimate values of each dimension + if (checkquery) { + available.datasets <- DataflowMethod(...)$DatabaseID + if (!is.element(databaseID, available.datasets)) { return(NULL) } } - r <- httr::GET(paste0('http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/',databaseID), httr::add_headers('user-agent' = '')) - if(httr::http_status(r)$reason != "OK"){ - return(list()) - } + h <- curl::new_handle() + h <- curl::handle_setopt(h, ...) + + r <- curl::curl_fetch_memory(url = paste0('http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/',databaseID), handle = h) + is_json <- log_query(r) + if (is_json[[1]]) stop(is_json[[2]]) + r.parsed <- jsonlite::fromJSON(rawToChar(r$content)) + + dim.code.list <- structure( + r.parsed$Structure$CodeLists$CodeList$Code, + names = r.parsed$Structure$CodeLists$CodeList$`@id` + )[r.parsed$Structure$KeyFamilies$KeyFamily$Components$Dimension$`@codelist`] + + dim.code.list <- purrr::map(dim.code.list, + function(x){ + data.frame(CodeValue = x$`@value`, + CodeText = x$Description$`#text`, + stringsAsFactors = FALSE)}) - r.parsed <- jsonlite::fromJSON(httr::content(r, "text")) - dim.code <- r.parsed$Structure$KeyFamilies$KeyFamily$Components$Dimension$`@codelist` - dim.code.list<- r.parsed$Structure$CodeLists$CodeList$Code - names(dim.code.list) <- r.parsed$Structure$CodeLists$CodeList$`@id` - dim.code.list <- dim.code.list[dim.code] - dim.code.list <- plyr::llply(dim.code.list, - function(x){ - data.frame(CodeValue = x$`@value`, - CodeText = x$Description$`#text`, - stringsAsFactors = FALSE)}) return(dim.code.list) } @@ -109,7 +119,7 @@ DataStructureMethod <- function(databaseID, checkquery = FALSE){ #' Each element of the list is a data frame with two columns; dimension code and dimension text(description). #' #' @examples -#' \donttest{ +#' \dontrun{ #' IFS.available.codes <- DataStructureMethod('IFS') # Get dimension code of IFS dataset #' names(IFS.available.codes) # Available dimension code #' IFS.available.codes[[1]] # Possible code in the first dimension @@ -118,29 +128,30 @@ DataStructureMethod <- function(databaseID, checkquery = FALSE){ #' CodeSearch(IFS.available.codes, 'CL_INDICATOR_IFS', 'GDPABCDE') # NULL #' } #' -#' @import httr -#' @import jsonlite #' @export CodeSearch <- function(available.codes, code, searchtext, search.value = TRUE, search.text = TRUE){ - if( ! is.element(code, names(available.codes))){ + if (!is.element(code, names(available.codes))) { stop(paste0("Code, ", code, ", does not exist.")) } match.index <- c() - if(search.value){ + + if (search.value) { code.value.match <- grep(searchtext, available.codes[[code]]$CodeValue) match.index <- unique(c(match.index, code.value.match)) } - if(search.text){ + + if (search.text) { code.text.match <- grep(searchtext, available.codes[[code]]$CodeText) match.index <- unique(c(match.index, code.text.match)) } - if(length(match.index) == 0){ + if (length(match.index) == 0) { warning('no match!') return(NULL) } + return(available.codes[[code]][match.index,]) } @@ -163,13 +174,14 @@ CodeSearch <- function(available.codes, code, searchtext, search.value = TRUE, s #' @param checkquery logical. If true, it will check the database ID is #' available or not. #' @param verbose logical. If true, it will print the exact API call. -#' @param tidy logical. If true, it will return a simple data fram. +#' @param tidy logical. If true, it will return a simple data frame. +#' @param ... parametres to pass to a curl handle (`?curl::handle_setopt`). #' #' @return A data frame. The last column, \code{Obs}, is a time series data #' described by other columns. #' #' @examples -#' \donttest{ +#' \dontrun{ #' databaseID <- 'IFS' #' startdate='2001-01-01' #' enddate='2016-12-31' @@ -233,84 +245,108 @@ CodeSearch <- function(available.codes, code, searchtext, search.value = TRUE, s #' US.query$Obs[[1]] # Monthly. US. TMG_CIF_USD CH #' } #' -#' @import httr -#' @import plyr -#' @import jsonlite #' @export CompactDataMethod <- function(databaseID, queryfilter=NULL, startdate='2001-01-01', enddate='2001-12-31', - checkquery = FALSE, verbose=FALSE, tidy=FALSE){ - if(checkquery){ - available.datasets <- DataflowMethod()$DatabaseID - if (!is.element(databaseID, available.datasets)){ + checkquery = FALSE, verbose=FALSE, tidy=FALSE, + ...){ + + if (checkquery) { + available.datasets <- DataflowMethod(...)$DatabaseID + if (!is.element(databaseID, available.datasets)) { stop('databaseID is not exist in API') return(NULL) } - acceptedquery <- DataStructureMethod(databaseID) - if (length(queryfilter) !=0 || - length(queryfilter) != length(acceptedquery)){ + + acceptedquery <- DataStructureMethod(databaseID, ...) + if (length(queryfilter) != 0 || + length(queryfilter) != length(acceptedquery)) { stop('queryfilter is wrong format') return(NULL) } } queryfilterstr <- '' - if (length(queryfilter) > 0){ + if (length(queryfilter) > 0) { queryfilterstr <- paste0( - unlist(plyr::llply(queryfilter, - function(x)(paste0(x, collapse="+")))), collapse=".") + purrr::map_chr(queryfilter, + function(x) paste0(x, collapse = "+")), + collapse = ".") } APIstr <- paste0('http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/', databaseID,'/',queryfilterstr, '?startPeriod=',startdate,'&endPeriod=',enddate) - r <- httr::GET(APIstr, httr::add_headers('user-agent' = '')) - if(verbose){ + if (verbose) { cat('\nmaking API call:\n') cat(APIstr) cat('\n') } - if(httr::http_status(r)$reason != "OK"){ - stop(paste(unlist(httr::http_status(r)))) - return(list()) - } - r.parsed <- jsonlite::fromJSON(httr::content(r, "text")) + h <- curl::new_handle() + h <- curl::handle_setopt(h, ...) - if(is.null(r.parsed$CompactData$DataSet$Series)){ + r <- curl::curl_fetch_memory(url = APIstr, handle = h) + is_json <- log_query(r) + if (is_json[[1]]) stop(is_json[[2]]) + r.parsed <- jsonlite::fromJSON(rawToChar(r$content)) + + if (is.null(r.parsed$CompactData$DataSet$Series)) { warning("No data available") return(NULL) } - if(class(r.parsed$CompactData$DataSet$Series) == "data.frame"){ - r.parsed$CompactData$DataSet$Series <- r.parsed$CompactData$DataSet$Series[!plyr::laply(r.parsed$CompactData$DataSet$Series$Obs, is.null),] - if(nrow(r.parsed$CompactData$DataSet$Series) ==0){ + if (class(r.parsed$CompactData$DataSet$Series) == "data.frame") { + r.parsed$CompactData$DataSet$Series <- r.parsed$CompactData$DataSet$Series[!purrr::map_lgl(r.parsed$CompactData$DataSet$Series$Obs, is.null),] + if (nrow(r.parsed$CompactData$DataSet$Series) == 0) { warning("No data available") return(NULL) } } - if(class(r.parsed$CompactData$DataSet$Series) == "list"){ - if(is.null(r.parsed$CompactData$DataSet$Series$Obs)){ + if (class(r.parsed$CompactData$DataSet$Series) == "list") { + if (is.null(r.parsed$CompactData$DataSet$Series$Obs)) { warning("No data available") return(NULL) } - ret.df <- as.data.frame(r.parsed$CompactData$DataSet$Series[1:(length(r.parsed$CompactData$DataSet$Series)-1)]) + + ret.df <- as.data.frame(r.parsed$CompactData$DataSet$Series[1:(length(r.parsed$CompactData$DataSet$Series) - 1)]) ret.df$Obs <- list(r.parsed$CompactData$DataSet$Series$Obs) names(ret.df) <- names(r.parsed$CompactData$DataSet$Series) r.parsed$CompactData$DataSet$Series <- ret.df } - if(tidy){ + if (tidy) { ret.df <- r.parsed$CompactData$DataSet$Series - for(i in 1:length(ret.df$Obs)){ - ret.df$Obs[[i]] <- merge(ret.df$Obs[[i]], ret.df[i,1:(ncol(ret.df)-1)]) + for (i in 1:length(ret.df$Obs)) { + ret.df$Obs[[i]] <- merge(ret.df$Obs[[i]], ret.df[i,1:(ncol(ret.df) - 1)]) } - ret.df <- plyr::ldply(ret.df$Obs) + ret.df <- dplyr::bind_rows(ret.df$Obs) return(ret.df) } return(r.parsed$CompactData$DataSet$Series) } + +#' @title log the result of a query if not json +#' +#' @description \code{log_query} write the query result to html file and returns TRUE and a stop message if the result +#' is not a JSON file. +#' +#' @return \code{log_query} returns TRUE and a stop message if the result +#' is not a JSON file or FALSE and an empty string +#' +#' @noRd + +log_query <- function(r) { + if (rawToChar(r$content[1]) != '{') { + filename <- tempfile('IMFData_querylog_', fileext = '.html') + writeLines(rawToChar(r$content), filename) + + return(list(TRUE, paste0('The query output is not formated JSON. The query output logged in the file : ', filename))) + } + + return(list(FALSE, '')) +} diff --git a/README.Rmd b/README.Rmd index 6edc635..f101e0e 100755 --- a/README.Rmd +++ b/README.Rmd @@ -51,8 +51,8 @@ If you don't know anything about [IMF data](http://data.imf.org) API, the follow ```{r, echo = TRUE, tidy=TRUE, cache=TRUE} availableDB <- DataflowMethod() -availableDB$DatabaseID -availableDB$DatabaseText +sample_lines <- sample.int(nrow(availableDB), 10) +availableDB[sample_lines, ] ``` ### Findout how many dimensions are available in a given dataset. Here, we use IFS(International Financial Statistics) for example, @@ -70,35 +70,37 @@ IFS.available.codes[[1]] ```{r, echo = TRUE, tidy=TRUE, cache=TRUE} # Search code contains GDP -CodeSearch(IFS.available.codes, 'CL_INDICATOR_IFS', 'GDP') +all_gdp_codes <- CodeSearch(IFS.available.codes, 'CL_INDICATOR_IFS', 'GDP') +sample_lines <- sample.int(nrow(all_gdp_codes), 10) +all_gdp_codes[sample_lines, ] ``` ### Make API call to get data ```{r, echo = TRUE, tidy=TRUE, cache=TRUE} databaseID <- 'IFS' -startdate='2001-01-01' -enddate='2016-12-31' -checkquery = FALSE +startdate <- '2001-01-01' +enddate <- '2016-12-31' +checkquery <- FALSE ## Germany, Norminal GDP in Euros, Norminal GDP in National Currency -queryfilter <- list(CL_FREA="", CL_AREA_IFS="GR", CL_INDICATOR_IFS =c("NGDP_EUR","NGDP_XDC")) -GR.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) -GR.NGDP.query[,1:5] -GR.NGDP.query$Obs[[1]] -GR.NGDP.query$Obs[[2]] - -## Quarterly, US, NGDP_SA_AR_XDC -queryfilter <- list(CL_FREA="Q", CL_AREA_IFS="US", CL_INDICATOR_IFS ="NGDP_SA_AR_XDC") +queryfilter <- list(CL_FREA = "", CL_AREA_IFS = "DE", CL_INDICATOR_IFS = c("NGDP_EUR","NGDP_XDC")) +DE.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) +DE.NGDP.query[,1:5] +tail(DE.NGDP.query$Obs[[1]]) +tail(DE.NGDP.query$Obs[[2]]) + +## Quarterly, US, NGDP_SA_XDC +queryfilter <- list(CL_FREA = "Q", CL_AREA_IFS = "US", CL_INDICATOR_IFS = "NGDP_SA_XDC") Q.US.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) Q.US.NGDP.query[,1:5] -Q.US.NGDP.query$Obs[[1]] +tail(Q.US.NGDP.query$Obs[[1]]) ## See exact API call to the data source -CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, verbose=TRUE)$Obs[[1]] +tail(CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, verbose = TRUE)$Obs[[1]]) ## Return a simple data frame -head(CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, tidy=TRUE)) +head(CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, tidy = TRUE)) ``` diff --git a/README.md b/README.md index d0ec56e..f78e086 100755 --- a/README.md +++ b/README.md @@ -1,147 +1,87 @@ -IMFData -======= -[![Build Status](http://travis-ci.org/mingjerli/IMFData.png?branch=master)](https://travis-ci.org/mingjerli/IMFData) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/IMFData)](https://cran.r-project.org/package=IMFData) +# IMFData -IMFData is an R package to access [IMF (Internation Monetary Fund) data](http://data.imf.org) . It has three main goals: +[![Build +Status](http://travis-ci.org/mingjerli/IMFData.png?branch=master)](https://travis-ci.org/mingjerli/IMFData) +[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/IMFData)](https://cran.r-project.org/package=IMFData) + +IMFData is an R package to access [IMF (Internation Monetary Fund) +data](http://data.imf.org) . It has three main goals: - Find out available datasets in the API. - Find out the dataset datastructure and code to use to make a query. - Query through the API. -Installation ------------- +## Installation Right now, you can install - from CRAN with - ``` r - install.packages('IMFData') - ``` +``` r +install.packages('IMFData') +``` - the latest development version from github with - ``` r - devtools::install_github('mingjerli/IMFData') - ``` +``` r +devtools::install_github('mingjerli/IMFData') +``` -Loading the package -------------------- +## Loading the package ``` r library(IMFData) ``` -How to use IMFData ------------------- +## How to use IMFData -If you don't know anything about [IMF data](http://data.imf.org) API, the following four steps is a good way to start. +If you don’t know anything about [IMF data](http://data.imf.org) API, +the following four steps is a good way to start. ### Find out available dataset in [IMF data](http://data.imf.org). ``` r availableDB <- DataflowMethod() -availableDB$DatabaseID -#> [1] "FSIRE" "FAS" "IFS" "MCDREO" -#> [5] "FSIBS" "FSI" "DOT" "FSIREM" -#> [9] "CDIS" "GFS01M" "GFS01" "BOP" -#> [13] "BOPAGG" "CPIS" "APDREO" "FM" -#> [17] "AFRREO" "MCDREO201410" "FM201410" "AFRREO201410" -#> [21] "MCDREO201501" "APDREO201410" "COMMP" "COMMPP" -#> [25] "WoRLD" "GFSR" "GFSSSUC" "GFSCOFOG" -#> [29] "GFSFALCS" "GFSIBS" "GFSMAB" "GFSE" -#> [33] "PGI" "WHDREO201504" "WCED" "WHDREO" -#> [37] "FM201504" "APDREO201504" "MCDREO201505" "AFRREO201504" -#> [41] "CDISARCHIVE" "ICSD" "HPDD" "COFR" -#> [45] "CPI" "IRFCL" "COFER" "FM201510" -#> [49] "RAFIT2AGG" "MCDREO201510" "WHDREO201510" "APDREO201510" -#> [53] "AFRREO201510" "GFSYR2014" "GFSYSSUC2014" "GFSYCOFOG2014" -#> [57] "GFSYIBS2014" "GFSYMAB2014" "GFSYFALCS2014" "GFSYE2014" -#> [61] "GFSIBS2015" "GFSR2015" "GFSFALCS2015" "GFSSSUC2015" -#> [65] "GFSMAB2015" "GFSCOFOG2015" "GFSE2015" "BOPSDMXUSD" -availableDB$DatabaseText -#> [1] "Financial Soundness Indicators (FSI), Reporting Entities" -#> [2] "Financial Access Survey (FAS)" -#> [3] "International Financial Statistics (IFS)" -#> [4] "Middle East and Central Asia Regional Economic Outlook (MCDREO)" -#> [5] "Financial Soundness Indicators (FSI), Balance Sheets" -#> [6] "Financial Soundness Indicators (FSI)" -#> [7] "Direction of Trade Statistics (DOTS)" -#> [8] "Financial Soundness Indicators (FSI), Reporting Entities - Multidimensional" -#> [9] "Coordinated Direct Investment Survey (CDIS)" -#> [10] "Government Finance Statistics (GFS 2001) - Multidimensional" -#> [11] "Government Finance Statistics (GFS 2001)" -#> [12] "Balance of Payments (BOP)" -#> [13] "Balance of Payments (BOP), World and Regional Aggregates" -#> [14] "Coordinated Portfolio Investment Survey (CPIS)" -#> [15] "Asia and Pacific Regional Economic Outlook (APDREO)" -#> [16] "Fiscal Monitor (FM)" -#> [17] "Sub-Saharan Africa Regional Economic Outlook (AFRREO)" -#> [18] "MCD Regional Economic Outlook October 2014" -#> [19] "Fiscal Monitor (FM) October 2014" -#> [20] "Sub-Saharan Africa Regional Economic Outlook (AFRREO) October 2014" -#> [21] "MCD Regional Economic Outlook January 2015" -#> [22] "Asia and Pacific Regional Economic Outlook (APDREO) October 2014" -#> [23] "Primary Commodity Prices" -#> [24] "Primary Commodity Prices Projections" -#> [25] "World Revenue Longitudinal Data (WoRLD)" -#> [26] "Government Finance Statistics (GFS), Revenue" -#> [27] "Government Finance Statistics (GFS), Statement of Sources and Uses of Cash" -#> [28] "Government Finance Statistics (GFS), Expenditure by Function of Government (COFOG)" -#> [29] "Government Finance Statistics (GFS), Financial Assets and Liabilities by Counterpart Sector" -#> [30] "Government Finance Statistics (GFS), Integrated Balance Sheet (Stock Positions and Flows in Assets and Liabilities)" -#> [31] "Government Finance Statistics (GFS), Main Aggregates and Balances" -#> [32] "Government Finance Statistics (GFS), Expense" -#> [33] "Principal Global Indicators (PGI)" -#> [34] "Western Hemisphere Regional Economic Outlook (WHDREO) April 2015" -#> [35] "World Commodity Exporters (WCED)" -#> [36] "Western Hemisphere Regional Economic Outlook (WHDREO)" -#> [37] "Fiscal Monitor (FM) April 2015" -#> [38] "Asia and Pacific Regional Economic Outlook (APDREO) April 2015" -#> [39] "MCD Regional Economic Outlook May 2015" -#> [40] "Sub-Saharan Africa Regional Economic Outlook (AFRREO) April 2015" -#> [41] "Coordinated Direct Investment Survey (CDIS) - Archive" -#> [42] "Investment and Capital Stock (ICSD)" -#> [43] "Historical Public Debt (HPDD)" -#> [44] "Coverage of Fiscal Reporting (COFR)" -#> [45] "Consumer Price Index (CPI)" -#> [46] "International Reserves and Foreign Currency Liquidity (IRFCL)" -#> [47] "Currency Composition of Official Foreign Exchange Reserves (COFER)" -#> [48] "Fiscal Monitor (FM) October 2015" -#> [49] "RA-FIT Round 2 Aggregates" -#> [50] "MCD Regional Economic Outlook (MCDREO) October 2015" -#> [51] "Western Hemisphere Regional Economic Outlook (WHDREO) October 2015" -#> [52] "Asia and Pacific Regional Economic Outlook (APDREO) October 2015" -#> [53] "Sub-Saharan Africa Regional Economic Outlook (AFRREO) October 2015" -#> [54] "Government Finance Statistics Yearbook (GFSY 2014), Revenue" -#> [55] "Government Finance Statistics Yearbook (GFSY 2014), Statement of Sources and Uses of Cash" -#> [56] "Government Finance Statistics Yearbook (GFSY 2014), Expenditure by Function of Government (COFOG)" -#> [57] "Government Finance Statistics Yearbook (GFSY 2014), Integrated Balance Sheet (Stock Positions and Flows in Assets and Liabilities)" -#> [58] "Government Finance Statistics Yearbook (GFSY 2014), Main Aggregates and Balances" -#> [59] "Government Finance Statistics Yearbook (GFSY 2014), Financial Assets and Liabilities by Counterpart Sector" -#> [60] "Government Finance Statistics Yearbook (GFSY 2014), Expense" -#> [61] "Government Finance Statistics Yearbook (GFSY 2015), Integrated Balance Sheet (Stock Positions and Flows in Assets and Liabilities)" -#> [62] "Government Finance Statistics Yearbook (GFSY 2015), Revenue" -#> [63] "Government Finance Statistics Yearbook (GFSY 2015), Financial Assets and Liabilities by Counterpart Sector" -#> [64] "Government Finance Statistics Yearbook (GFSY 2015), Statement of Sources and Uses of Cash" -#> [65] "Government Finance Statistics Yearbook (GFSY 2015), Main Aggregates and Balances" -#> [66] "Government Finance Statistics Yearbook (GFSY 2015), Expenditure by Function of Government (COFOG)" -#> [67] "Government Finance Statistics Yearbook (GFSY 2015), Expense" -#> [68] "Balance of Payments (BOP), Global SDMX (US Dollars)" +#> {"Structure":{"@xmlns:xsd":"http://www.w3.org/2001/XMLSchema","@xmlns:xsi":"http://www.w3.org/2001/X +sample_lines <- sample.int(nrow(availableDB), 10) +availableDB[sample_lines, ] +#> DatabaseID +#> 91 FAS_2017 +#> 150 IFS_2020M03 +#> 76 GFSCOFOG2015 +#> 14 WHDREO201504 +#> 114 AFRREO201504 +#> 88 AFRREO201904 +#> 32 DOT_2017Q2 +#> 210 IFS_2021M02 +#> 197 IFS_DISCONTINUED +#> 129 GFSSSUC2015 +#> DatabaseText +#> 91 Financial Access Survey (FAS), 2017 +#> 150 International Financial Statistics (IFS), 2020 M03 +#> 76 Government Finance Statistics Yearbook (GFSY 2015), Expenditure by Function of Government (COFOG) +#> 14 Western Hemisphere Regional Economic Outlook (WHDREO) April 2015 +#> 114 Sub-Saharan Africa Regional Economic Outlook (AFRREO) April 2015 +#> 88 Sub-Saharan Africa Regional Economic Outlook (AFRREO) April 2019 +#> 32 Direction of Trade Statistics (DOTS), 2017 Q2 +#> 210 International Financial Statistics (IFS), 2021 M02 +#> 197 International Financial Statistics (IFS), Discontinued Series +#> 129 Government Finance Statistics Yearbook (GFSY 2015), Statement of Sources and Uses of Cash ``` ### Findout how many dimensions are available in a given dataset. Here, we use IFS(International Financial Statistics) for example, ``` r # Get dimension code of IFS dataset -IFS.available.codes <- DataStructureMethod("IFS") +IFS.available.codes <- DataStructureMethod('IFS') +#> {"Structure":{"@xmlns:xsd":"http://www.w3.org/2001/XMLSchema","@xmlns:xsi":"http://www.w3.org/2001/X # Available dimension code names(IFS.available.codes) #> [1] "CL_FREQ" "CL_AREA_IFS" "CL_INDICATOR_IFS" # Possible code in the first dimension -IFS.available.codes[[1]] +IFS.available.codes[[1]] #> CodeValue CodeText #> 1 A Annual #> 2 B Bi-annual @@ -151,344 +91,108 @@ IFS.available.codes[[1]] #> 6 W Weekly ``` -### Search possible code to use in each dimension. Here, we want to search code related to GDP in CL\_INDICATOR\_IFS dimension, +### Search possible code to use in each dimension. Here, we want to search code related to GDP in CL_INDICATOR_IFS dimension, ``` r # Search code contains GDP -CodeSearch(IFS.available.codes, "CL_INDICATOR_IFS", "GDP") -#> CodeValue -#> 1464 GGXWDG_G01_GDP_PT -#> 1468 GGX_G01_GDP_PT -#> 1486 GGR_G01_GDP_PT -#> 1567 NGDP_F_XDC -#> 1568 NGDP_D_IX -#> 1569 NGDP_D_PC_CP_A_PT -#> 1570 NGDP_D_SA_IX -#> 1571 NGDP_AR_XDC -#> 1572 NGDP_EUR -#> 1573 NGDP_XDC -#> 1574 NGDP_SA_AR_XDC -#> 1575 NGDP_SA_EUR -#> 1576 NGDP_SA_XDC -#> 1577 NGDP_USD -#> 1578 NGDP_R_AR_XDC -#> 1579 NGDP_R_EUR -#> 1580 NGDP_R_F_XDC -#> 1581 NGDP_R_IX -#> 1582 NGDP_R_XDC -#> 1583 NGDP_R_PT -#> 1584 NGDP_R_CH_SA_AR_XDC -#> 1585 NGDP_R_SA_AR_XDC -#> 1586 NGDP_R_SA_EUR -#> 1587 NGDP_R_SA_IX -#> 1588 NGDP_R_SA_XDC -#> 1597 NGDPNPI_AR_XDC -#> 1598 NGDPNPI_EUR -#> 1599 NGDPNPI_XDC -#> 1600 NGDPNPI_SA_AR_XDC -#> 1601 NGDPNPI_SA_EUR -#> 1602 NGDPNPI_SA_XDC -#> 1603 NGDPNPI_USD -#> 2606 NSDGDP_EUR -#> 2607 NSDGDP_XDC -#> 2608 NSDGDP_SA_AR_XDC -#> 2609 NSDGDP_USD -#> 2671 All_Indicators_Excluding_NGDP_Indicators -#> CodeText -#> 1464 General Government, Gross debt position, 2001 Manual, Percent of GDP, Percent -#> 1468 General Government, Memo Item: Expenditure, 2001 Manual, Percent of GDP, Percent -#> 1486 General Government, Revenue, 2001 Manual, Percent of GDP, Percent -#> 1567 Gross Domestic Product, at Factor Cost, National Currency -#> 1568 Gross Domestic Product, Deflator, Index -#> 1569 Gross Domestic Product, Deflator, Percentage change, corresponding period previous year, Percent -#> 1570 Gross Domestic Product, Deflator, Seasonally adjusted, Index -#> 1571 Gross Domestic Product, Nominal, Annualized Rate, National Currency -#> 1572 Gross Domestic Product, Nominal, Euro -#> 1573 Gross Domestic Product, Nominal, National Currency -#> 1574 Gross Domestic Product, Nominal, Seasonally adjusted, annualized Rate, National Currency -#> 1575 Gross Domestic Product, Nominal, Seasonally Adjusted, Euros -#> 1576 Gross Domestic Product, Nominal, Seasonally Adjusted, National Currency -#> 1577 Gross Domestic Product, Nominal, US Dollars -#> 1578 Gross Domestic Product, Real, Annualized Rate, National Currency -#> 1579 Gross Domestic Product, Real, Euros -#> 1580 Gross Domestic Product, Real, Factor Cost, National Currency -#> 1581 Gross Domestic Product, Real, Index -#> 1582 Gross Domestic Product, Real, National Currency -#> 1583 Gross Domestic Product, Real, Percent -#> 1584 Gross Domestic Product, Real, Reference chained, seasonally adjusted, Annualized Rate, National Currency -#> 1585 Gross Domestic Product, Real, Seasonally adjusted, Annualized Rate, National Currency -#> 1586 Gross Domestic Product, Real, Seasonally Adjusted, Euros -#> 1587 Gross Domestic Product, Real, Seasonally adjusted, Index -#> 1588 Gross Domestic Product, Real, Seasonally Adjusted, National Currency -#> 1597 Income Receipts from Rest of the World less Income Payments to the Rest of the World, Annualized Rate, National Currency -#> 1598 Income Receipts from Rest of the World less Income Payments to the Rest of the World, Euros -#> 1599 Income Receipts from Rest of the World less Income Payments to the Rest of the World, National Currency -#> 1600 Income Receipts from Rest of the World less Income Payments to the Rest of the World, Seasonally adjusted, annualized Rate, National Currency -#> 1601 Income Receipts from Rest of the World less Income Payments to the Rest of the World, Seasonally adjusted, Euro -#> 1602 Income Receipts from Rest of the World less Income Payments to the Rest of the World, Seasonally Adjusted, National Currency -#> 1603 Income Receipts from Rest of the World less Income Payments to the Rest of the World, US Dollars -#> 2606 Statistical Discrepancy in GDP, Nominal, Euros -#> 2607 Statistical Discrepancy in GDP, Nominal, National Currency -#> 2608 Statistical Discrepancy in GDP, Nominal, Seasonally adjusted, Annualized Rate, National Currency -#> 2609 Statistical Discrepancy in GDP, Nominal, US Dollars -#> 2671 All Indicators Excluding NGDP Indicators +all_gdp_codes <- CodeSearch(IFS.available.codes, 'CL_INDICATOR_IFS', 'GDP') +sample_lines <- sample.int(nrow(all_gdp_codes), 10) +all_gdp_codes[sample_lines, ] +#> CodeValue +#> 714 NGDP_R_PC_CP_A_PT +#> 710 NGDP_PC_PP_PT +#> 1631 NNITSPX_SA_XDC +#> 713 NGDP_R_XDC +#> 719 NGDP_R_CH_SA_XDC +#> 1599 NSDGDP_XDC +#> 1603 NSDGDP_R_PYP_XDC +#> 702 NGDP_D_PC_CP_A_PT +#> 705 NGDP_D_PC_PP_SA_PT +#> 1632 NGDPT_XDC +#> CodeText +#> 714 National Accounts, Expenditure, Gross Domestic Product, Real, Percentage change, corresponding period previous year, Percent +#> 710 National Accounts, Expenditure, Gross Domestic Product, Nominal, Percentage change, previous period, Percent +#> 1631 National Accounts, GDP-GNP Relation, National Income, Taxes on Production and Imports less Subsidies, Nominal, Seasonally adjusted, Domestic Currency +#> 713 National Accounts, Expenditure, Gross Domestic Product, Real, Domestic Currency +#> 719 National Accounts, Expenditure, Gross Domestic Product, Real, Reference Chained, Seasonally adjusted, Domestic Currency +#> 1599 National Accounts, Statistical Discrepancy in GDP, Nominal, Domestic Currency +#> 1603 Statistical Discrepancy, Real, Previous year prices, Domestic Currency +#> 702 National Accounts, Expenditure, Gross Domestic Product, Deflator, Percentage change, corresponding period previous year, Percent +#> 705 National Accounts, Expenditure, Gross Domestic Product, Deflator, Percentage change, previous period, Seasonally adjusted, Percent +#> 1632 National Accounts, NGDPT, Nominal, Domestic Currency ``` ### Make API call to get data ``` r -databaseID <- "IFS" -startdate = "2001-01-01" -enddate = "2016-12-31" -checkquery = FALSE +databaseID <- 'IFS' +startdate <- '2001-01-01' +enddate <- '2016-12-31' +checkquery <- FALSE ## Germany, Norminal GDP in Euros, Norminal GDP in National Currency -queryfilter <- list(CL_FREA = "", CL_AREA_IFS = "GR", CL_INDICATOR_IFS = c("NGDP_EUR", - "NGDP_XDC")) -GR.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, - checkquery) -GR.NGDP.query[, 1:5] +queryfilter <- list(CL_FREA = "", CL_AREA_IFS = "DE", CL_INDICATOR_IFS = c("NGDP_EUR","NGDP_XDC")) +DE.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) +#> {"CompactData":{"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@xmlns:xsd":"http://www.w3 +DE.NGDP.query[,1:5] #> @FREQ @REF_AREA @INDICATOR @UNIT_MULT @TIME_FORMAT -#> 2 Q GR NGDP_EUR 9 P3M -#> 4 A GR NGDP_EUR 9 P1Y -GR.NGDP.query$Obs[[1]] -#> @TIME_PERIOD @OBS_VALUE @OBS_STATUS -#> 1 2001-Q1 35.2366 K -#> 2 2001-Q2 36.7264 -#> 3 2001-Q3 39.8428 -#> 4 2001-Q4 40.3881 -#> 5 2002-Q1 37.4971 -#> 6 2002-Q2 39.8739 -#> 7 2002-Q3 42.3377 -#> 8 2002-Q4 43.752 -#> 9 2003-Q1 40.8806 -#> 10 2003-Q2 43.4188 -#> 11 2003-Q3 46.6817 -#> 12 2003-Q4 47.9238 -#> 13 2004-Q1 44.8781 -#> 14 2004-Q2 47.604999892938 -#> 15 2004-Q3 50.8154 -#> 16 2004-Q4 50.4173 -#> 17 2005-Q1 45.727 -#> 18 2005-Q2 49.1768012641032 -#> 19 2005-Q3 51.7502 -#> 20 2005-Q4 52.5883 -#> 21 2006-Q1 50.0931 -#> 22 2006-Q2 53.9923 -#> 23 2006-Q3 55.9232 -#> 24 2006-Q4 57.8529 -#> 25 2007-Q1 52.8308 -#> 26 2007-Q2 58.359 -#> 27 2007-Q3 59.929 -#> 28 2007-Q4 61.5758 -#> 29 2008-Q1 55.8782 -#> 30 2008-Q2 60.746 -#> 31 2008-Q3 63.0783 -#> 32 2008-Q4 62.2879 -#> 33 2009-Q1 53.3813 -#> 34 2009-Q2 60.2148 -#> 35 2009-Q3 61.2555 -#> 36 2009-Q4 62.6826 -#> 37 2010-Q1 54.2695 -#> 38 2010-Q2 57.379 -#> 39 2010-Q3 57.6284 -#> 40 2010-Q4 56.7546 -#> 41 2011-Q1 48.8302 -#> 42 2011-Q2 53.0734 -#> 43 2011-Q3 53.7756 -#> 44 2011-Q4 51.3496 -#> 45 2012-Q1 45.0995 -#> 46 2012-Q2 48.4733 -#> 47 2012-Q3 49.7557 -#> 48 2012-Q4 47.8755 -#> 49 2013-Q1 42.1708 -#> 50 2013-Q2 45.8799 -#> 51 2013-Q3 47.5605 -#> 52 2013-Q4 44.7779 -#> 53 2014-Q1 40.4676 -#> 54 2014-Q2 44.3952 -#> 55 2014-Q3 48.0023 -#> 56 2014-Q4 44.6942 -#> 57 2015-Q1 40.4384 -#> 58 2015-Q2 44.6036 -#> 59 2015-Q3 46.7534 -#> 60 2015-Q4 44.2277 -#> 61 2016-Q1 39.9625 -#> 62 2016-Q2 45.1606 -GR.NGDP.query$Obs[[2]] -#> @TIME_PERIOD @OBS_VALUE @OBS_STATUS -#> 1 2001 151.9872 K -#> 2 2002 162.2742 -#> 3 2003 178.5709 -#> 4 2004 193.715823551657 -#> 5 2005 199.242311837475 -#> 6 2006 217.861568188497 -#> 7 2007 232.694592661749 -#> 8 2008 241.990389906673 -#> 9 2009 237.534181456484 -#> 10 2010 226.031447205434 -#> 11 2011 207.028875339588 -#> 12 2012 191.203907934554 -#> 13 2013 180.389043118584 -#> 14 2014 177.55942109271 -#> 15 2015 176.022666208548 - -## Quarterly, US, NGDP_SA_AR_XDC -queryfilter <- list(CL_FREA = "Q", CL_AREA_IFS = "US", CL_INDICATOR_IFS = "NGDP_SA_AR_XDC") -Q.US.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, - checkquery) -Q.US.NGDP.query[, 1:5] -#> @FREQ @REF_AREA @INDICATOR @UNIT_MULT @TIME_FORMAT -#> 1 Q US NGDP_SA_AR_XDC 9 P3M -Q.US.NGDP.query$Obs[[1]] +#> 1 A DE NGDP_XDC 6 P1Y +#> 2 Q DE NGDP_XDC 6 P3M +tail(DE.NGDP.query$Obs[[1]]) +#> @TIME_PERIOD @OBS_VALUE +#> 11 2011 2693560 +#> 12 2012 2745310 +#> 13 2013 2811350 +#> 14 2014 2927430 +#> 15 2015 3026180 +#> 16 2016 3134740 +tail(DE.NGDP.query$Obs[[2]]) +#> @TIME_PERIOD @OBS_VALUE +#> 59 2015-Q3 765670 +#> 60 2015-Q4 781320 +#> 61 2016-Q1 762950 +#> 62 2016-Q2 779080 +#> 63 2016-Q3 788980 +#> 64 2016-Q4 803730 + +## Quarterly, US, NGDP_SA_XDC +queryfilter <- list(CL_FREA = "Q", CL_AREA_IFS = "US", CL_INDICATOR_IFS = "NGDP_SA_XDC") +Q.US.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) +#> {"CompactData":{"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@xmlns:xsd":"http://www.w3 +Q.US.NGDP.query[,1:5] +#> @FREQ @REF_AREA @INDICATOR @UNIT_MULT @TIME_FORMAT +#> 1 Q US NGDP_SA_XDC 6 P3M +tail(Q.US.NGDP.query$Obs[[1]]) #> @TIME_PERIOD @OBS_VALUE -#> 1 2001-Q1 10508.1 -#> 2 2001-Q2 10638.4 -#> 3 2001-Q3 10639.5 -#> 4 2001-Q4 10701.3 -#> 5 2002-Q1 10834.4 -#> 6 2002-Q2 10934.8 -#> 7 2002-Q3 11037.1 -#> 8 2002-Q4 11103.8 -#> 9 2003-Q1 11230.1 -#> 10 2003-Q2 11370.7 -#> 11 2003-Q3 11625.1 -#> 12 2003-Q4 11816.8 -#> 13 2004-Q1 11988.4 -#> 14 2004-Q2 12181.4 -#> 15 2004-Q3 12367.7 -#> 16 2004-Q4 12562.2 -#> 17 2005-Q1 12813.7 -#> 18 2005-Q2 12974.1 -#> 19 2005-Q3 13205.4 -#> 20 2005-Q4 13381.6 -#> 21 2006-Q1 13648.9 -#> 22 2006-Q2 13799.8 -#> 23 2006-Q3 13908.5 -#> 24 2006-Q4 14066.4 -#> 25 2007-Q1 14233.2 -#> 26 2007-Q2 14422.3 -#> 27 2007-Q3 14569.7 -#> 28 2007-Q4 14685.3 -#> 29 2008-Q1 14668.4 -#> 30 2008-Q2 14813 -#> 31 2008-Q3 14843 -#> 32 2008-Q4 14549.9 -#> 33 2009-Q1 14383.9 -#> 34 2009-Q2 14340.4 -#> 35 2009-Q3 14384.1 -#> 36 2009-Q4 14566.5 -#> 37 2010-Q1 14681.1 -#> 38 2010-Q2 14888.6 -#> 39 2010-Q3 15057.7 -#> 40 2010-Q4 15230.2 -#> 41 2011-Q1 15238.4 -#> 42 2011-Q2 15460.9 -#> 43 2011-Q3 15587.1 -#> 44 2011-Q4 15785.3 -#> 45 2012-Q1 15973.9 -#> 46 2012-Q2 16121.9 -#> 47 2012-Q3 16227.9 -#> 48 2012-Q4 16297.3 -#> 49 2013-Q1 16475.4 -#> 50 2013-Q2 16541.4 -#> 51 2013-Q3 16749.3 -#> 52 2013-Q4 16999.9 -#> 53 2014-Q1 17025.2 -#> 54 2014-Q2 17285.6 -#> 55 2014-Q3 17569.4 -#> 56 2014-Q4 17692.2 -#> 57 2015-Q1 17783.6 -#> 58 2015-Q2 17998.3 -#> 59 2015-Q3 18141.9 -#> 60 2015-Q4 18222.8 -#> 61 2016-Q1 18281.6 -#> 62 2016-Q2 18437.6 +#> 59 2015-Q3 18347425 +#> 60 2015-Q4 18378803 +#> 61 2016-Q1 18470156 +#> 62 2016-Q2 18656207 +#> 63 2016-Q3 18821359 +#> 64 2016-Q4 19032580 ## See exact API call to the data source -CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, verbose = TRUE)$Obs[[1]] +tail(CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, verbose = TRUE)$Obs[[1]]) #> #> making API call: -#> http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/Q.US.NGDP_SA_AR_XDC?startPeriod=2001-01-01&endPeriod=2016-12-31 +#> http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/Q.US.NGDP_SA_XDC?startPeriod=2001-01-01&endPeriod=2016-12-31 +#> {"CompactData":{"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@xmlns:xsd":"http://www.w3 #> @TIME_PERIOD @OBS_VALUE -#> 1 2001-Q1 10508.1 -#> 2 2001-Q2 10638.4 -#> 3 2001-Q3 10639.5 -#> 4 2001-Q4 10701.3 -#> 5 2002-Q1 10834.4 -#> 6 2002-Q2 10934.8 -#> 7 2002-Q3 11037.1 -#> 8 2002-Q4 11103.8 -#> 9 2003-Q1 11230.1 -#> 10 2003-Q2 11370.7 -#> 11 2003-Q3 11625.1 -#> 12 2003-Q4 11816.8 -#> 13 2004-Q1 11988.4 -#> 14 2004-Q2 12181.4 -#> 15 2004-Q3 12367.7 -#> 16 2004-Q4 12562.2 -#> 17 2005-Q1 12813.7 -#> 18 2005-Q2 12974.1 -#> 19 2005-Q3 13205.4 -#> 20 2005-Q4 13381.6 -#> 21 2006-Q1 13648.9 -#> 22 2006-Q2 13799.8 -#> 23 2006-Q3 13908.5 -#> 24 2006-Q4 14066.4 -#> 25 2007-Q1 14233.2 -#> 26 2007-Q2 14422.3 -#> 27 2007-Q3 14569.7 -#> 28 2007-Q4 14685.3 -#> 29 2008-Q1 14668.4 -#> 30 2008-Q2 14813 -#> 31 2008-Q3 14843 -#> 32 2008-Q4 14549.9 -#> 33 2009-Q1 14383.9 -#> 34 2009-Q2 14340.4 -#> 35 2009-Q3 14384.1 -#> 36 2009-Q4 14566.5 -#> 37 2010-Q1 14681.1 -#> 38 2010-Q2 14888.6 -#> 39 2010-Q3 15057.7 -#> 40 2010-Q4 15230.2 -#> 41 2011-Q1 15238.4 -#> 42 2011-Q2 15460.9 -#> 43 2011-Q3 15587.1 -#> 44 2011-Q4 15785.3 -#> 45 2012-Q1 15973.9 -#> 46 2012-Q2 16121.9 -#> 47 2012-Q3 16227.9 -#> 48 2012-Q4 16297.3 -#> 49 2013-Q1 16475.4 -#> 50 2013-Q2 16541.4 -#> 51 2013-Q3 16749.3 -#> 52 2013-Q4 16999.9 -#> 53 2014-Q1 17025.2 -#> 54 2014-Q2 17285.6 -#> 55 2014-Q3 17569.4 -#> 56 2014-Q4 17692.2 -#> 57 2015-Q1 17783.6 -#> 58 2015-Q2 17998.3 -#> 59 2015-Q3 18141.9 -#> 60 2015-Q4 18222.8 -#> 61 2016-Q1 18281.6 -#> 62 2016-Q2 18437.6 +#> 59 2015-Q3 18347425 +#> 60 2015-Q4 18378803 +#> 61 2016-Q1 18470156 +#> 62 2016-Q2 18656207 +#> 63 2016-Q3 18821359 +#> 64 2016-Q4 19032580 ## Return a simple data frame -head(CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, - tidy = TRUE)) -#> @TIME_PERIOD @OBS_VALUE @FREQ @REF_AREA @INDICATOR @UNIT_MULT -#> 1 2001-Q1 10508.1 Q US NGDP_SA_AR_XDC 9 -#> 2 2001-Q2 10638.4 Q US NGDP_SA_AR_XDC 9 -#> 3 2001-Q3 10639.5 Q US NGDP_SA_AR_XDC 9 -#> 4 2001-Q4 10701.3 Q US NGDP_SA_AR_XDC 9 -#> 5 2002-Q1 10834.4 Q US NGDP_SA_AR_XDC 9 -#> 6 2002-Q2 10934.8 Q US NGDP_SA_AR_XDC 9 -#> @TIME_FORMAT -#> 1 P3M -#> 2 P3M -#> 3 P3M -#> 4 P3M -#> 5 P3M -#> 6 P3M +head(CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, tidy = TRUE)) +#> {"CompactData":{"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@xmlns:xsd":"http://www.w3 +#> @TIME_PERIOD @OBS_VALUE @FREQ @REF_AREA @INDICATOR @UNIT_MULT @TIME_FORMAT +#> 1 2001-Q1 10472879 Q US NGDP_SA_XDC 6 P3M +#> 2 2001-Q2 10597822 Q US NGDP_SA_XDC 6 P3M +#> 3 2001-Q3 10596294 Q US NGDP_SA_XDC 6 P3M +#> 4 2001-Q4 10660294 Q US NGDP_SA_XDC 6 P3M +#> 5 2002-Q1 10788952 Q US NGDP_SA_XDC 6 P3M +#> 6 2002-Q2 10893207 Q US NGDP_SA_XDC 6 P3M ``` diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..be3b9dc --- /dev/null +++ b/docs/404.html @@ -0,0 +1,145 @@ + + + + + + + + +Page not found (404) • IMFData + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +Content not found. Please use links in the navbar. + +
+ + + +
+ + + +
+ + +
+

Site built with pkgdown 1.6.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html new file mode 100644 index 0000000..aa88b2b --- /dev/null +++ b/docs/LICENSE-text.html @@ -0,0 +1,147 @@ + + + + + + + + +License • IMFData + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
YEAR: 2016
+COPYRIGHT HOLDER: Ming-Jer Lee
+
+ +
+ + + +
+ + + +
+ + +
+

Site built with pkgdown 1.6.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/authors.html b/docs/authors.html new file mode 100644 index 0000000..ce2506f --- /dev/null +++ b/docs/authors.html @@ -0,0 +1,144 @@ + + + + + + + + +Authors • IMFData + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
    +
  • +

    Ming-Jer Lee. Author, maintainer. +

    +
  • +
+ +
+ +
+ + + +
+ + +
+

Site built with pkgdown 1.6.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css new file mode 100644 index 0000000..5a85941 --- /dev/null +++ b/docs/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js new file mode 100644 index 0000000..1cdd573 --- /dev/null +++ b/docs/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docs/docsearch.css b/docs/docsearch.css new file mode 100644 index 0000000..e5f1fe1 --- /dev/null +++ b/docs/docsearch.css @@ -0,0 +1,148 @@ +/* Docsearch -------------------------------------------------------------- */ +/* + Source: https://github.com/algolia/docsearch/ + License: MIT +*/ + +.algolia-autocomplete { + display: block; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 +} + +.algolia-autocomplete .ds-dropdown-menu { + width: 100%; + min-width: none; + max-width: none; + padding: .75rem 0; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, .1); + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); +} + +@media (min-width:768px) { + .algolia-autocomplete .ds-dropdown-menu { + width: 175% + } +} + +.algolia-autocomplete .ds-dropdown-menu::before { + display: none +} + +.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { + padding: 0; + background-color: rgb(255,255,255); + border: 0; + max-height: 80vh; +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { + margin-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0; + overflow: visible +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + padding: .125rem 1rem; + margin-top: 0; + font-size: 1.3em; + font-weight: 500; + color: #00008B; + border-bottom: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + float: none; + padding-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: none; + width: auto; + padding: 0; + text-align: left +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + float: none; + width: auto; + padding: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content::before { + display: none +} + +.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { + padding-top: .75rem; + margin-top: .75rem; + border-top: 1px solid rgba(0, 0, 0, .1) +} + +.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { + display: block; + padding: .1rem 1rem; + margin-bottom: 0.1; + font-size: 1.0em; + font-weight: 400 + /* display: none */ +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + display: block; + padding: .25rem 1rem; + margin-bottom: 0; + font-size: 0.9em; + font-weight: 400 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + padding: 0 1rem .5rem; + margin-top: -.25rem; + font-size: 0.8em; + font-weight: 400; + line-height: 1.25 +} + +.algolia-autocomplete .algolia-docsearch-footer { + width: 110px; + height: 20px; + z-index: 3; + margin-top: 10.66667px; + float: right; + font-size: 0; + line-height: 0; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background-image: url("data:image/svg+xml;utf8,"); + background-repeat: no-repeat; + background-position: 50%; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 100%; + height: 100%; + display: block; + transform: translate(-8px); +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + color: #FF8C00; + background: rgba(232, 189, 54, 0.1) +} + + +.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { + box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) +} + +.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { + background-color: rgba(192, 192, 192, .15) +} diff --git a/docs/docsearch.js b/docs/docsearch.js new file mode 100644 index 0000000..b35504c --- /dev/null +++ b/docs/docsearch.js @@ -0,0 +1,85 @@ +$(function() { + + // register a handler to move the focus to the search bar + // upon pressing shift + "/" (i.e. "?") + $(document).on('keydown', function(e) { + if (e.shiftKey && e.keyCode == 191) { + e.preventDefault(); + $("#search-input").focus(); + } + }); + + $(document).ready(function() { + // do keyword highlighting + /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ + var mark = function() { + + var referrer = document.URL ; + var paramKey = "q" ; + + if (referrer.indexOf("?") !== -1) { + var qs = referrer.substr(referrer.indexOf('?') + 1); + var qs_noanchor = qs.split('#')[0]; + var qsa = qs_noanchor.split('&'); + var keyword = ""; + + for (var i = 0; i < qsa.length; i++) { + var currentParam = qsa[i].split('='); + + if (currentParam.length !== 2) { + continue; + } + + if (currentParam[0] == paramKey) { + keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); + } + } + + if (keyword !== "") { + $(".contents").unmark({ + done: function() { + $(".contents").mark(keyword); + } + }); + } + } + }; + + mark(); + }); +}); + +/* Search term highlighting ------------------------------*/ + +function matchedWords(hit) { + var words = []; + + var hierarchy = hit._highlightResult.hierarchy; + // loop to fetch from lvl0, lvl1, etc. + for (var idx in hierarchy) { + words = words.concat(hierarchy[idx].matchedWords); + } + + var content = hit._highlightResult.content; + if (content) { + words = words.concat(content.matchedWords); + } + + // return unique words + var words_uniq = [...new Set(words)]; + return words_uniq; +} + +function updateHitURL(hit) { + + var words = matchedWords(hit); + var url = ""; + + if (hit.anchor) { + url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; + } else { + url = hit.url + '?q=' + escape(words.join(" ")); + } + + return url; +} diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..4f1fc7b --- /dev/null +++ b/docs/index.html @@ -0,0 +1,316 @@ + + + + + + + +R Interface for International Monetary Fund(IMF) Data API • IMFData + + + + + + + + + + +
    +
    + + + + +
    +
    +
    + + +

    IMFData is an R package to access IMF (Internation Monetary Fund) data . It has three main goals:

    +
      +
    • Find out available datasets in the API.
    • +
    • Find out the dataset datastructure and code to use to make a query.
    • +
    • Query through the API.
    • +
    +
    +

    +Installation

    +

    Right now, you can install

    +
      +
    • from CRAN with
    • +
    +
    +install.packages('IMFData')
    +
      +
    • the latest development version from github with
    • +
    +
    +devtools::install_github('mingjerli/IMFData')
    +
    +
    +

    +Loading the package

    + +
    +
    +

    +How to use IMFData

    +

    If you don’t know anything about IMF data API, the following four steps is a good way to start.

    +
    +

    +Find out available dataset in IMF data.

    +
    +availableDB <- DataflowMethod()
    +#> {"Structure":{"@xmlns:xsd":"http://www.w3.org/2001/XMLSchema","@xmlns:xsi":"http://www.w3.org/2001/X
    +sample_lines <- sample.int(nrow(availableDB), 10)
    +availableDB[sample_lines, ]
    +#>           DatabaseID
    +#> 91          FAS_2017
    +#> 150      IFS_2020M03
    +#> 76      GFSCOFOG2015
    +#> 14      WHDREO201504
    +#> 114     AFRREO201504
    +#> 88      AFRREO201904
    +#> 32        DOT_2017Q2
    +#> 210      IFS_2021M02
    +#> 197 IFS_DISCONTINUED
    +#> 129      GFSSSUC2015
    +#>                                                                                          DatabaseText
    +#> 91                                                                Financial Access Survey (FAS), 2017
    +#> 150                                                International Financial Statistics (IFS), 2020 M03
    +#> 76  Government Finance Statistics Yearbook (GFSY 2015), Expenditure by Function of Government (COFOG)
    +#> 14                                   Western Hemisphere Regional Economic Outlook (WHDREO) April 2015
    +#> 114                                  Sub-Saharan Africa Regional Economic Outlook (AFRREO) April 2015
    +#> 88                                   Sub-Saharan Africa Regional Economic Outlook (AFRREO) April 2019
    +#> 32                                                      Direction of Trade Statistics (DOTS), 2017 Q2
    +#> 210                                                International Financial Statistics (IFS), 2021 M02
    +#> 197                                     International Financial Statistics (IFS), Discontinued Series
    +#> 129         Government Finance Statistics Yearbook (GFSY 2015), Statement of Sources and Uses of Cash
    +
    +
    +

    +Findout how many dimensions are available in a given dataset. Here, we use IFS(International Financial Statistics) for example,

    +
    +# Get dimension code of IFS dataset
    +IFS.available.codes <- DataStructureMethod('IFS')
    +#> {"Structure":{"@xmlns:xsd":"http://www.w3.org/2001/XMLSchema","@xmlns:xsi":"http://www.w3.org/2001/X
    +# Available dimension code
    +names(IFS.available.codes)
    +#> [1] "CL_FREQ"          "CL_AREA_IFS"      "CL_INDICATOR_IFS"
    +# Possible code in the first dimension
    +IFS.available.codes[[1]] 
    +#>   CodeValue  CodeText
    +#> 1         A    Annual
    +#> 2         B Bi-annual
    +#> 3         Q Quarterly
    +#> 4         M   Monthly
    +#> 5         D     Daily
    +#> 6         W    Weekly
    +
    + +
    +

    +Make API call to get data

    +
    +databaseID <- 'IFS'
    +startdate <- '2001-01-01'
    +enddate <- '2016-12-31'
    +checkquery <- FALSE
    +
    +## Germany, Norminal GDP in Euros, Norminal GDP in National Currency
    +queryfilter <- list(CL_FREA = "", CL_AREA_IFS = "DE", CL_INDICATOR_IFS = c("NGDP_EUR","NGDP_XDC"))
    +DE.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery)
    +#> {"CompactData":{"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@xmlns:xsd":"http://www.w3
    +DE.NGDP.query[,1:5]
    +#>   @FREQ @REF_AREA @INDICATOR @UNIT_MULT @TIME_FORMAT
    +#> 1     A        DE   NGDP_XDC          6          P1Y
    +#> 2     Q        DE   NGDP_XDC          6          P3M
    +tail(DE.NGDP.query$Obs[[1]])
    +#>    @TIME_PERIOD @OBS_VALUE
    +#> 11         2011    2693560
    +#> 12         2012    2745310
    +#> 13         2013    2811350
    +#> 14         2014    2927430
    +#> 15         2015    3026180
    +#> 16         2016    3134740
    +tail(DE.NGDP.query$Obs[[2]])
    +#>    @TIME_PERIOD @OBS_VALUE
    +#> 59      2015-Q3     765670
    +#> 60      2015-Q4     781320
    +#> 61      2016-Q1     762950
    +#> 62      2016-Q2     779080
    +#> 63      2016-Q3     788980
    +#> 64      2016-Q4     803730
    +
    +## Quarterly, US, NGDP_SA_XDC
    +queryfilter <- list(CL_FREA = "Q", CL_AREA_IFS = "US", CL_INDICATOR_IFS = "NGDP_SA_XDC")
    +Q.US.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery)
    +#> {"CompactData":{"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@xmlns:xsd":"http://www.w3
    +Q.US.NGDP.query[,1:5]
    +#>   @FREQ @REF_AREA  @INDICATOR @UNIT_MULT @TIME_FORMAT
    +#> 1     Q        US NGDP_SA_XDC          6          P3M
    +tail(Q.US.NGDP.query$Obs[[1]])
    +#>    @TIME_PERIOD @OBS_VALUE
    +#> 59      2015-Q3   18347425
    +#> 60      2015-Q4   18378803
    +#> 61      2016-Q1   18470156
    +#> 62      2016-Q2   18656207
    +#> 63      2016-Q3   18821359
    +#> 64      2016-Q4   19032580
    +
    +## See exact API call to the data source
    +tail(CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, verbose = TRUE)$Obs[[1]])
    +#> 
    +#> making API call:
    +#> http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/Q.US.NGDP_SA_XDC?startPeriod=2001-01-01&endPeriod=2016-12-31
    +#> {"CompactData":{"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@xmlns:xsd":"http://www.w3
    +#>    @TIME_PERIOD @OBS_VALUE
    +#> 59      2015-Q3   18347425
    +#> 60      2015-Q4   18378803
    +#> 61      2016-Q1   18470156
    +#> 62      2016-Q2   18656207
    +#> 63      2016-Q3   18821359
    +#> 64      2016-Q4   19032580
    +
    +## Return a simple data frame
    +head(CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery, tidy = TRUE))
    +#> {"CompactData":{"@xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@xmlns:xsd":"http://www.w3
    +#>   @TIME_PERIOD @OBS_VALUE @FREQ @REF_AREA  @INDICATOR @UNIT_MULT @TIME_FORMAT
    +#> 1      2001-Q1   10472879     Q        US NGDP_SA_XDC          6          P3M
    +#> 2      2001-Q2   10597822     Q        US NGDP_SA_XDC          6          P3M
    +#> 3      2001-Q3   10596294     Q        US NGDP_SA_XDC          6          P3M
    +#> 4      2001-Q4   10660294     Q        US NGDP_SA_XDC          6          P3M
    +#> 5      2002-Q1   10788952     Q        US NGDP_SA_XDC          6          P3M
    +#> 6      2002-Q2   10893207     Q        US NGDP_SA_XDC          6          P3M
    +
    +
    +
    +
    + + +
    + + +
    + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + diff --git a/docs/link.svg b/docs/link.svg new file mode 100644 index 0000000..88ad827 --- /dev/null +++ b/docs/link.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/docs/pkgdown.css b/docs/pkgdown.css new file mode 100644 index 0000000..1273238 --- /dev/null +++ b/docs/pkgdown.css @@ -0,0 +1,367 @@ +/* Sticky footer */ + +/** + * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ + * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css + * + * .Site -> body > .container + * .Site-content -> body > .container .row + * .footer -> footer + * + * Key idea seems to be to ensure that .container and __all its parents__ + * have height set to 100% + * + */ + +html, body { + height: 100%; +} + +body { + position: relative; +} + +body > .container { + display: flex; + height: 100%; + flex-direction: column; +} + +body > .container .row { + flex: 1 0 auto; +} + +footer { + margin-top: 45px; + padding: 35px 0 36px; + border-top: 1px solid #e5e5e5; + color: #666; + display: flex; + flex-shrink: 0; +} +footer p { + margin-bottom: 0; +} +footer div { + flex: 1; +} +footer .pkgdown { + text-align: right; +} +footer p { + margin-bottom: 0; +} + +img.icon { + float: right; +} + +img { + max-width: 100%; +} + +/* Fix bug in bootstrap (only seen in firefox) */ +summary { + display: list-item; +} + +/* Typographic tweaking ---------------------------------*/ + +.contents .page-header { + margin-top: calc(-60px + 1em); +} + +dd { + margin-left: 3em; +} + +/* Section anchors ---------------------------------*/ + +a.anchor { + margin-left: -30px; + display:inline-block; + width: 30px; + height: 30px; + visibility: hidden; + + background-image: url(./link.svg); + background-repeat: no-repeat; + background-size: 20px 20px; + background-position: center center; +} + +.hasAnchor:hover a.anchor { + visibility: visible; +} + +@media (max-width: 767px) { + .hasAnchor:hover a.anchor { + visibility: hidden; + } +} + + +/* Fixes for fixed navbar --------------------------*/ + +.contents h1, .contents h2, .contents h3, .contents h4 { + padding-top: 60px; + margin-top: -40px; +} + +/* Navbar submenu --------------------------*/ + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu>.dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover>.dropdown-menu { + display: block; +} + +.dropdown-submenu>a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #cccccc; + margin-top: 5px; + margin-right: -10px; +} + +.dropdown-submenu:hover>a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left>.dropdown-menu { + left: -100%; + margin-left: 10px; + border-radius: 6px 0 6px 6px; +} + +/* Sidebar --------------------------*/ + +#pkgdown-sidebar { + margin-top: 30px; + position: -webkit-sticky; + position: sticky; + top: 70px; +} + +#pkgdown-sidebar h2 { + font-size: 1.5em; + margin-top: 1em; +} + +#pkgdown-sidebar h2:first-child { + margin-top: 0; +} + +#pkgdown-sidebar .list-unstyled li { + margin-bottom: 0.5em; +} + +/* bootstrap-toc tweaks ------------------------------------------------------*/ + +/* All levels of nav */ + +nav[data-toggle='toc'] .nav > li > a { + padding: 4px 20px 4px 6px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; +} + +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 5px; + color: inherit; + border-left: 1px solid #878787; +} + +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 5px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; + border-left: 2px solid #878787; +} + +/* Nav: second level (shown on .active) */ + +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} + +nav[data-toggle='toc'] .nav .nav > li > a { + padding-left: 16px; + font-size: 1.35rem; +} + +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 15px; +} + +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 15px; + font-weight: 500; + font-size: 1.35rem; +} + +/* orcid ------------------------------------------------------------------- */ + +.orcid { + font-size: 16px; + color: #A6CE39; + /* margins are required by official ORCID trademark and display guidelines */ + margin-left:4px; + margin-right:4px; + vertical-align: middle; +} + +/* Reference index & topics ----------------------------------------------- */ + +.ref-index th {font-weight: normal;} + +.ref-index td {vertical-align: top; min-width: 100px} +.ref-index .icon {width: 40px;} +.ref-index .alias {width: 40%;} +.ref-index-icons .alias {width: calc(40% - 40px);} +.ref-index .title {width: 60%;} + +.ref-arguments th {text-align: right; padding-right: 10px;} +.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} +.ref-arguments .name {width: 20%;} +.ref-arguments .desc {width: 80%;} + +/* Nice scrolling for wide elements --------------------------------------- */ + +table { + display: block; + overflow: auto; +} + +/* Syntax highlighting ---------------------------------------------------- */ + +pre { + word-wrap: normal; + word-break: normal; + border: 1px solid #eee; +} + +pre, code { + background-color: #f8f8f8; + color: #333; +} + +pre code { + overflow: auto; + word-wrap: normal; + white-space: pre; +} + +pre .img { + margin: 5px 0; +} + +pre .img img { + background-color: #fff; + display: block; + height: auto; +} + +code a, pre a { + color: #375f84; +} + +a.sourceLine:hover { + text-decoration: none; +} + +.fl {color: #1514b5;} +.fu {color: #000000;} /* function */ +.ch,.st {color: #036a07;} /* string */ +.kw {color: #264D66;} /* keyword */ +.co {color: #888888;} /* comment */ + +.message { color: black; font-weight: bolder;} +.error { color: orange; font-weight: bolder;} +.warning { color: #6A0366; font-weight: bolder;} + +/* Clipboard --------------------------*/ + +.hasCopyButton { + position: relative; +} + +.btn-copy-ex { + position: absolute; + right: 0; + top: 0; + visibility: hidden; +} + +.hasCopyButton:hover button.btn-copy-ex { + visibility: visible; +} + +/* headroom.js ------------------------ */ + +.headroom { + will-change: transform; + transition: transform 200ms linear; +} +.headroom--pinned { + transform: translateY(0%); +} +.headroom--unpinned { + transform: translateY(-100%); +} + +/* mark.js ----------------------------*/ + +mark { + background-color: rgba(255, 255, 51, 0.5); + border-bottom: 2px solid rgba(255, 153, 51, 0.3); + padding: 1px; +} + +/* vertical spacing after htmlwidgets */ +.html-widget { + margin-bottom: 10px; +} + +/* fontawesome ------------------------ */ + +.fab { + font-family: "Font Awesome 5 Brands" !important; +} + +/* don't display links in code chunks when printing */ +/* source: https://stackoverflow.com/a/10781533 */ +@media print { + code a:link:after, code a:visited:after { + content: ""; + } +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js new file mode 100644 index 0000000..7e7048f --- /dev/null +++ b/docs/pkgdown.js @@ -0,0 +1,108 @@ +/* http://gregfranko.com/blog/jquery-best-practices/ */ +(function($) { + $(function() { + + $('.navbar-fixed-top').headroom(); + + $('body').css('padding-top', $('.navbar').height() + 10); + $(window).resize(function(){ + $('body').css('padding-top', $('.navbar').height() + 10); + }); + + $('[data-toggle="tooltip"]').tooltip(); + + var cur_path = paths(location.pathname); + var links = $("#navbar ul li a"); + var max_length = -1; + var pos = -1; + for (var i = 0; i < links.length; i++) { + if (links[i].getAttribute("href") === "#") + continue; + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); + + var length = prefix_length(nav_path, cur_path); + if (length > max_length) { + max_length = length; + pos = i; + } + } + + // Add class to parent
  • , and enclosing
  • if in dropdown + if (pos >= 0) { + var menu_anchor = $(links[pos]); + menu_anchor.parent().addClass("active"); + menu_anchor.closest("li.dropdown").addClass("active"); + } + }); + + function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); + } + + // Returns -1 if not found + function prefix_length(needle, haystack) { + if (needle.length > haystack.length) + return(-1); + + // Special case for length-0 haystack, since for loop won't run + if (haystack.length === 0) { + return(needle.length === 0 ? 0 : -1); + } + + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(i); + } + + return(haystack.length); + } + + /* Clipboard --------------------------*/ + + function changeTooltipMessage(element, msg) { + var tooltipOriginalTitle=element.getAttribute('data-original-title'); + element.setAttribute('data-original-title', msg); + $(element).tooltip('show'); + element.setAttribute('data-original-title', tooltipOriginalTitle); + } + + if(ClipboardJS.isSupported()) { + $(document).ready(function() { + var copyButton = ""; + + $(".examples, div.sourceCode").addClass("hasCopyButton"); + + // Insert copy buttons: + $(copyButton).prependTo(".hasCopyButton"); + + // Initialize tooltips: + $('.btn-copy-ex').tooltip({container: 'body'}); + + // Initialize clipboard: + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { + text: function(trigger) { + return trigger.parentNode.textContent; + } + }); + + clipboardBtnCopies.on('success', function(e) { + changeTooltipMessage(e.trigger, 'Copied!'); + e.clearSelection(); + }); + + clipboardBtnCopies.on('error', function() { + changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); + }); + }); + } +})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml new file mode 100644 index 0000000..d1393c7 --- /dev/null +++ b/docs/pkgdown.yml @@ -0,0 +1,6 @@ +pandoc: '2.13' +pkgdown: 1.6.1 +pkgdown_sha: ~ +articles: {} +last_built: 2021-05-05T21:26Z + diff --git a/docs/reference/CodeSearch.html b/docs/reference/CodeSearch.html new file mode 100644 index 0000000..5f53e96 --- /dev/null +++ b/docs/reference/CodeSearch.html @@ -0,0 +1,197 @@ + + + + + + + + +Search Available Code in a Dimension of a Given Dataset — CodeSearch • IMFData + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    CodeSearch search matching codes in a given dimension of a dataset

    +
    + +
    CodeSearch(
    +  available.codes,
    +  code,
    +  searchtext,
    +  search.value = TRUE,
    +  search.text = TRUE
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    available.codes

    string. Database ID of the dataset.

    code

    string. Dimension code get from DataStructureMethod.

    searchtext

    string. String to search in the dimension code.

    search.value

    logical. If true, it will search searchtext in CodeValue.

    search.text

    logical. If true, it will search searchtext in CodeText.

    + +

    Value

    + +

    A list for each dimension. +The name of the list is the dimension name. +Each element of the list is a data frame with two columns; dimension code and dimension text(description).

    + +

    Examples

    +
    if (FALSE) { +IFS.available.codes <- DataStructureMethod('IFS') # Get dimension code of IFS dataset +names(IFS.available.codes) # Available dimension code +IFS.available.codes[[1]] # Possible code in the first dimension +CodeSearch(IFS.available.codes, 'CLL', 'GDP') # Error (CLL is not a dimension code of IFS dataset) +CodeSearch(IFS.available.codes, 'CL_INDICATOR_IFS', 'GDP') # Search code contains GDP +CodeSearch(IFS.available.codes, 'CL_INDICATOR_IFS', 'GDPABCDE') # NULL +} + +
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/CompactDataMethod.html b/docs/reference/CompactDataMethod.html new file mode 100644 index 0000000..b9e9e98 --- /dev/null +++ b/docs/reference/CompactDataMethod.html @@ -0,0 +1,276 @@ + + + + + + + + +Make Query to Get Data from the API — CompactDataMethod • IMFData + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    CompactDataMethod will make an API call with filter +(if not NULL) to get data of each available code in the data set. It might +only return incomplete data because of API limit. In this case, try to add +more constraints in the filter.

    +
    + +
    CompactDataMethod(
    +  databaseID,
    +  queryfilter = NULL,
    +  startdate = "2001-01-01",
    +  enddate = "2001-12-31",
    +  checkquery = FALSE,
    +  verbose = FALSE,
    +  tidy = FALSE,
    +  ...
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    databaseID

    A character string. Database ID for the dataset. Can be +obtained from DataflowMethod

    queryfilter

    list. A list that contains filter to use in the API call. +If not NULL, it must be a list with the lengtho of dimension of dataset. If +NULL, no filter has been set.

    startdate

    string. Start date in format of "YYYY-mm-dd".

    enddate

    string. End date in format of "YYYY-mm-dd".

    checkquery

    logical. If true, it will check the database ID is +available or not.

    verbose

    logical. If true, it will print the exact API call.

    tidy

    logical. If true, it will return a simple data frame.

    ...

    parametres to pass to a curl handle (`?curl::handle_setopt`).

    + +

    Value

    + +

    A data frame. The last column, Obs, is a time series data +described by other columns.

    + +

    Examples

    +
    if (FALSE) { +databaseID <- 'IFS' +startdate='2001-01-01' +enddate='2016-12-31' +checkquery = FALSE + +IFS.available.codes <- DataStructureMethod('IFS') + +## Germany, Norminal GDP in Euros, Norminal GDP in National Currency +queryfilter <- list(CL_FREA="", CL_AREA_IFS="GR", CL_INDICATOR_IFS =c("NGDP_EUR","NGDP_XDC")) +GR.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) +GR.NGDP.query[,1:5] +GR.NGDP.query$Obs[[1]] +GR.NGDP.query$Obs[[2]] + +## Example for verbose +GR.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, verbose=TRUE) + +## Example for tidy +GR.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, tidy=TRUE) +head(GR.NGDP.query) + +## Quarterly, Germany, Norminal GDP in Euros, Norminal GDP in National Currency +queryfilter <- list(CL_FREA="Q", CL_AREA_IFS="GR", CL_INDICATOR_IFS =c("NGDP_EUR","NGDP_XDC")) +Q.GR.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) +Q.GR.NGDP.query[,1:5] +Q.GR.NGDP.query$Obs[[1]] + +## Quarterly, USA +queryfilter <- list(CL_FREA="Q", CL_AREA_IFS="US", CL_INDICATOR_IFS = "") +Q.US.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) +Q.US.query[,1:5] +CodeSearch(IFS.available.codes, "CL_INDICATOR_IFS", "FITB_3M_PA") # Reverse look up meaning of code + +## Quarterly, USA, GDP related +IFS.available.codes <- DataStructureMethod('IFS') +ALLGDPCodeValue <- CodeSearch(IFS.available.codes, "CL_INDICATOR_IFS","GDP")$CodeValue +queryfilter <- list(CL_FREA="Q", CL_AREA_IFS="US", CL_INDICATOR_IFS =ALLGDPCodeValue[1:10]) +Q.US.GDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) +Q.US.GDP.query[,1:5] +Q.US.GDP.query$Obs[[1]] +Q.US.GDP.query$Obs[[2]] + +## Quarterly, US, NGDP_SA_AR_XDC +queryfilter <- list(CL_FREA="Q", CL_AREA_IFS="US", CL_INDICATOR_IFS ="NGDP_SA_AR_XDC") +Q.US.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) +Q.US.NGDP.query[,1:5] +Q.US.NGDP.query$Obs[[1]] + +## Monthly, US, NGDP_SA_AR_XDC +queryfilter <- list(CL_FREA="M", CL_AREA_IFS="", CL_INDICATOR_IFS ="NGDP_SA_AR_XDC") +M.NGDP.query <- CompactDataMethod(databaseID, queryfilter, startdate, enddate, checkquery) +M.NGDP.query$Obs # NULL + +## Example for DOT dataset +DOT.available.codes <- DataStructureMethod('DOT') +names(DOT.available.codes) +queryfilter <- list(CL_FREQ = "", CL_AREA_DOT="US", + CL_INDICATOR_DOT = "", CL_COUNTERPART_AREA_DOT="") +US.query <- CompactDataMethod('DOT', queryfilter, startdate, enddate, FALSE) +US.query[1:5,1:(length(US.query)-1)] +US.query$Obs[[1]] # Monthly. US. TMG_CIF_USD CH +} + +
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/DataStructureMethod.html b/docs/reference/DataStructureMethod.html new file mode 100644 index 0000000..1428a5f --- /dev/null +++ b/docs/reference/DataStructureMethod.html @@ -0,0 +1,182 @@ + + + + + + + + +Get List of Dimension of a Given Dataset — DataStructureMethod • IMFData + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    DataStructureMethod get the data structure of dataset with available code and description for each dimension.

    +
    + +
    DataStructureMethod(databaseID, checkquery = FALSE, ...)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    databaseID

    string. Database ID of the dataset. Obtained from DataflowMethod.

    checkquery

    logical. If true, it will check the database ID is available or not.

    ...

    parametres to pass to a curl handle (`?curl::handle_setopt`).

    + +

    Value

    + +

    DataStructureMethod returns a list of data frame to describe available dimensions in the dataset. +The name of the list is the dimension name. +Each element of the list is a data frame with two columns;

    +

    CodeValue - dimension code used for CompactDataMethod.
    +CodeText - dimension description.

    + +

    Examples

    +
    if (FALSE) { +available.codes <- DataStructureMethod('IFS') +names(available.codes) +available.codes[[1]]#' +} + +
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/DataflowMethod.html b/docs/reference/DataflowMethod.html new file mode 100644 index 0000000..94ccc80 --- /dev/null +++ b/docs/reference/DataflowMethod.html @@ -0,0 +1,176 @@ + + + + + + + + +Get List of Available Datasets from API — DataflowMethod • IMFData + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    DataflowMethod returns a data frame with availble +datasets

    +
    + +
    DataflowMethod(...)
    + +

    Arguments

    + + + + + + +
    ...

    parametres to pass to a curl handle (`?curl::handle_setopt`).

    + +

    Value

    + +

    DataflowMethod returns a data frame object to describe +available datasets from IMF data API. This data frame includes the following +two columns:

    +

    DatabaseID - Database ID uses for making API call
    +DatabaseText - Database description

    + +

    Examples

    +
    if (FALSE) { +availableDB <- DataflowMethod() +availableDB +availableDB$DatabaseID[1] +} + +
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png new file mode 100644 index 0000000000000000000000000000000000000000..17a358060aed2a86950757bbd25c6f92c08c458f GIT binary patch literal 1011 zcmeAS@N?(olHy`uVBq!ia0y~yV0-|=9Be?5+AI5}0x7m6Z+90U4Fo@(ch>_c&H|6f zVg?3oArNM~bhqvg0|WD9PZ!6KiaBo&GBN^{G%5UFpXcEKVvd5*5Eu=C0SJK)8A6*F U7`aXvEC5;V>FVdQ&MBb@00SN#Z2$lO literal 0 HcmV?d00001 diff --git a/docs/reference/index.html b/docs/reference/index.html new file mode 100644 index 0000000..dd94d96 --- /dev/null +++ b/docs/reference/index.html @@ -0,0 +1,188 @@ + + + + + + + + +Function reference • IMFData + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    All functions

    +

    +
    +

    CodeSearch()

    +

    Search Available Code in a Dimension of a Given Dataset

    +

    CompactDataMethod()

    +

    Make Query to Get Data from the API

    +

    DataStructureMethod()

    +

    Get List of Dimension of a Given Dataset

    +

    DataflowMethod()

    +

    Get List of Available Datasets from API

    +
    + + +
    + + + +
    + + + + + + + + diff --git a/man/CodeSearch.Rd b/man/CodeSearch.Rd index 9cd6bb9..07bc5b1 100644 --- a/man/CodeSearch.Rd +++ b/man/CodeSearch.Rd @@ -4,8 +4,13 @@ \alias{CodeSearch} \title{Search Available Code in a Dimension of a Given Dataset} \usage{ -CodeSearch(available.codes, code, searchtext, search.value = TRUE, - search.text = TRUE) +CodeSearch( + available.codes, + code, + searchtext, + search.value = TRUE, + search.text = TRUE +) } \arguments{ \item{available.codes}{string. Database ID of the dataset.} @@ -27,7 +32,7 @@ Each element of the list is a data frame with two columns; dimension code and di \code{CodeSearch} search matching codes in a given dimension of a dataset } \examples{ -\donttest{ +\dontrun{ IFS.available.codes <- DataStructureMethod('IFS') # Get dimension code of IFS dataset names(IFS.available.codes) # Available dimension code IFS.available.codes[[1]] # Possible code in the first dimension @@ -37,4 +42,3 @@ CodeSearch(IFS.available.codes, 'CL_INDICATOR_IFS', 'GDPABCDE') # NULL } } - diff --git a/man/CompactDataMethod.Rd b/man/CompactDataMethod.Rd index ff20c57..da18b1f 100644 --- a/man/CompactDataMethod.Rd +++ b/man/CompactDataMethod.Rd @@ -4,9 +4,16 @@ \alias{CompactDataMethod} \title{Make Query to Get Data from the API} \usage{ -CompactDataMethod(databaseID, queryfilter = NULL, startdate = "2001-01-01", - enddate = "2001-12-31", checkquery = FALSE, verbose = FALSE, - tidy = FALSE) +CompactDataMethod( + databaseID, + queryfilter = NULL, + startdate = "2001-01-01", + enddate = "2001-12-31", + checkquery = FALSE, + verbose = FALSE, + tidy = FALSE, + ... +) } \arguments{ \item{databaseID}{A character string. Database ID for the dataset. Can be @@ -25,7 +32,9 @@ available or not.} \item{verbose}{logical. If true, it will print the exact API call.} -\item{tidy}{logical. If true, it will return a simple data fram.} +\item{tidy}{logical. If true, it will return a simple data frame.} + +\item{...}{parametres to pass to a curl handle (`?curl::handle_setopt`).} } \value{ A data frame. The last column, \code{Obs}, is a time series data @@ -38,7 +47,7 @@ only return incomplete data because of API limit. In this case, try to add more constraints in the filter. } \examples{ -\donttest{ +\dontrun{ databaseID <- 'IFS' startdate='2001-01-01' enddate='2016-12-31' @@ -103,4 +112,3 @@ US.query$Obs[[1]] # Monthly. US. TMG_CIF_USD CH } } - diff --git a/man/DataStructureMethod.Rd b/man/DataStructureMethod.Rd index 42693e1..7accb28 100644 --- a/man/DataStructureMethod.Rd +++ b/man/DataStructureMethod.Rd @@ -4,12 +4,14 @@ \alias{DataStructureMethod} \title{Get List of Dimension of a Given Dataset} \usage{ -DataStructureMethod(databaseID, checkquery = FALSE) +DataStructureMethod(databaseID, checkquery = FALSE, ...) } \arguments{ \item{databaseID}{string. Database ID of the dataset. Obtained from \code{DataflowMethod}.} \item{checkquery}{logical. If true, it will check the database ID is available or not.} + +\item{...}{parametres to pass to a curl handle (`?curl::handle_setopt`).} } \value{ \code{DataStructureMethod} returns a list of data frame to describe available dimensions in the dataset. @@ -23,11 +25,10 @@ CodeText - dimension description. \code{DataStructureMethod} get the data structure of dataset with available code and description for each dimension. } \examples{ -\donttest{ +\dontrun{ available.codes <- DataStructureMethod('IFS') names(available.codes) available.codes[[1]]#' } } - diff --git a/man/DataflowMethod.Rd b/man/DataflowMethod.Rd index c632955..60fb0b9 100644 --- a/man/DataflowMethod.Rd +++ b/man/DataflowMethod.Rd @@ -4,7 +4,10 @@ \alias{DataflowMethod} \title{Get List of Available Datasets from API} \usage{ -DataflowMethod() +DataflowMethod(...) +} +\arguments{ +\item{...}{parametres to pass to a curl handle (`?curl::handle_setopt`).} } \value{ \code{DataflowMethod} returns a data frame object to describe @@ -19,10 +22,10 @@ DatabaseText - Database description datasets } \examples{ -\donttest{ +\dontrun{ availableDB <- DataflowMethod() availableDB availableDB$DatabaseID[1] } -} +}