Skip to content

Commit

Permalink
version 0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobtz authored and cran-robot committed Jan 26, 2024
1 parent 0a209aa commit 31a37a7
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 30 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: imf.data
Title: An Interface to IMF (International Monetary Fund) Data JSON API
Version: 0.1.3
Version: 0.1.4
Authors@R:
person("Pedro", "Baltazar",, "pedrobtz@gmail.com", role = c("aut", "cre"))
Description: A straightforward interface for accessing the IMF
Expand All @@ -21,8 +21,8 @@ Config/testthat/edition: 3
URL: https://pedrobtz.github.io/imf.data/
BugReports: https://github.com/pedrobtz/imf.data/issues
NeedsCompilation: no
Packaged: 2023-11-27 20:44:10 UTC; pbtz
Packaged: 2024-01-25 16:00:55 UTC; pbtz
Author: Pedro Baltazar [aut, cre]
Maintainer: Pedro Baltazar <pedrobtz@gmail.com>
Repository: CRAN
Date/Publication: 2023-11-28 10:00:06 UTC
Date/Publication: 2024-01-25 22:20:02 UTC
18 changes: 9 additions & 9 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
6eb754fbd25c5207f7f36f94a6f78d65 *DESCRIPTION
bc40a1b313b4e6f030ae2296efc0e599 *DESCRIPTION
4b4dc26a2562dc2187d00821cbe32e36 *LICENSE
4b4a95efc195552823cbe2b6923db362 *NAMESPACE
a0605dd1222d50fda640c0ddd5557995 *NEWS.md
0402dc39f9eebe8fe19c32d5a6f028e4 *R/database.R
da868b7e4774aea2c941b4c79a96df46 *R/methods.R
b00879866b19f046db53f5d269d4e13c *NEWS.md
fa4ba5a8be6600706d2b34a7bc61e891 *R/database.R
13e7d1b711b7556a03a41806f538eb53 *R/methods.R
c3c4f326dca8c8e795db55b8da1d242b *R/package.R
1277d734fbc34b933e56626f0145e627 *R/request.R
6cd1949e458a43656c057a196a632af2 *R/settings.R
c751abddc9a7ff6175afb6e68c8b9018 *R/zzz.R
12d39ce2f244b33e673e6807fee0678c *R/zzz.R
4f53bd6a34ef91467dd46ed8f81779a2 *man/imf.data-package.Rd
63a0a2f9a8836eba31e3ffac204b12ef *man/list_datasets.Rd
481f6b12ead2c813ebd2c4905a10137d *man/list_datasets.Rd
005c4713445b3f4d4d27623d096f9a14 *man/load_datasets.Rd
ef7f25f7ba423f03250f545a1b9e63f5 *man/mt_compact_data.Rd
a144f113508088575e9ad36284751210 *man/mt_data_structure.Rd
88030fcead6b5fddbc83a0932fb23a18 *man/mt_dataflow.Rd
daf7f49e305fed80ce94691361105c50 *man/mt_compact_data.Rd
74cdd32bd999fd229239f07c620868e1 *man/mt_data_structure.Rd
e628bb61a03ba7ca1b6e5c65fe1f8b6a *man/mt_dataflow.Rd
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# imf.data

# imf.data 0.1.4

* set 'curl' timeout to 5 minutes.

# imf.data 0.1.3

* improve error handling, when service responds with html message.
Expand Down
18 changes: 13 additions & 5 deletions R/database.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
#' @export
#'
#' @examples
#' list_datasets()
#'
#' d <- list_datasets()
#' head(d)

list_datasets <- function(){
x <- mt_dataflow()
if(is.null(x)) return(invisible(NULL))
res <- data.frame(ID = sapply(x,function(y)y$KeyFamilyRef$KeyFamilyID),
Description = sapply(x,function(y)y$Name$`#text`))
res <- res[ order(res$ID), ]
rownames(res) <- NULL
return(res)
}

Expand Down Expand Up @@ -74,7 +75,7 @@ load_datasets <- local({
}

series <- cbind_series(transform_series(series, dimensions))

row.names(series) <- NULL
return(series)
}

Expand Down Expand Up @@ -127,6 +128,7 @@ extract_dimension_names <- function(data_str){
colnames(res) <- c("Codelist", "Name")
res$Name <- tolower(res$Name)
res$Num <- seq_along(res$Name)
row.names(res) <- NULL
return(res)
}

Expand All @@ -142,6 +144,7 @@ extract_dimension_values <- function(data_str, dimensions){
lapply(ls_values, function(x){
x <- x[, c("@value","Description.#text")]
colnames(x) <- c("Value","Description")
row.names(x) <- NULL
return(x)
})
}
Expand Down Expand Up @@ -210,9 +213,11 @@ cbind_series <- function(series){

stopifnot(is.list(series), length(series) > 1L)

Reduce(x = series, function(x,y){
res <- Reduce(x = series, function(x,y){
merge(x, y, by = "TIME_PERIOD", all = TRUE)
})
row.names(res) <- NULL
return(res)
}

rbind_list <- function(x){
Expand All @@ -231,7 +236,9 @@ rbind_list <- function(x){
return(y)
})

return(Reduce(rbind, res))
res <- Reduce(rbind, res)
row.names(res) <- NULL
return(res)
}

transform_series <- function(series, dimensions){
Expand All @@ -252,5 +259,6 @@ transform_series <- function(series, dimensions){
return(d)
})

row.names(res) <- NULL
return(res)
}
10 changes: 5 additions & 5 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#'
#' @returns a list with content of 'Dataflow' response.
#' @examples
#' mt_dataflow()
#' DF <- mt_dataflow()
#'
#' @export
mt_dataflow <- local({
Expand All @@ -28,7 +28,7 @@ mt_dataflow <- local({
#' @returns a list with content of 'DataStructure' response.
#'
#' @examples
#' mt_data_structure("DOT")
#' DOT <- mt_data_structure("DOT")
#'
#' @export
mt_data_structure <- function(id){
Expand Down Expand Up @@ -63,9 +63,9 @@ mt_data_structure <- function(id){
#' 'yyyy', 'yyyy-mm' or 'yyyy-mm-dd'.
#'
#' @examples
#' mt_compact_data("IFS", list("M", "GB", "PMP_IX"))
#' mt_compact_data("IFS", list("M", "GB", "PMP_IX"), start_period = "2000-01")
#' mt_compact_data("DOT", list("M","GB", "TMG_CIF_USD", c("B0","W00")))
#' IFS <- mt_compact_data("IFS", list("M", "GB", "PMP_IX"))
#' IFS <- mt_compact_data("IFS", list("M", "GB", "PMP_IX"), start_period = "2000-01")
#' DOT <- mt_compact_data("DOT", list("M","GB", "TMG_CIF_USD", c("B0","W00")))
#'
#' @export
mt_compact_data <- function(id,
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@


.onAttach <- function(libname, pkgname) {

settings$verbose(FALSE)
settings$handle_options(list(timeout_ms = 60*5*1000))
# limit 7 requests per 5 seconds window
request_limit$set_rate(limit = 7, window = 5)
}
4 changes: 2 additions & 2 deletions man/list_datasets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/mt_compact_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mt_data_structure.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mt_dataflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 31a37a7

Please sign in to comment.