Skip to content

Commit

Permalink
Merge pull request #72 from pachadotdev/master
Browse files Browse the repository at this point in the history
v 4.5 with simpler vignettes
  • Loading branch information
pachadotdev committed Jun 29, 2023
2 parents 0088f2f + b73c20e commit ec04943
Show file tree
Hide file tree
Showing 21 changed files with 411 additions and 7,423 deletions.
96 changes: 39 additions & 57 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,70 +1,52 @@
Package: tradestatistics
Type: Package
Package: tradestatistics
Title: Open Trade Statistics API Wrapper and Utility Program
Version: 4.4.0
Version: 4.5.0
Authors@R: c(
person(given = "Mauricio",
family = "Vargas",
role = c("aut", "cre", "cph"),
email = "mavargas11@uc.cl",
comment = c(ORCID = "0000-0003-1017-7574")),
person(given = "Joshua",
family = "Kunst",
role = "ctb",
comment = "contributed to different parts of the pre-release code"),
person(given = "Alexey",
family = "Kravchenko",
role = "ctb",
comment = "reviewed 2021 version of the API"),
person(given = "Emma",
family = "Mendelsohn",
role = "ctb",
comment = "updated the functions to take available years from the API instead of hardcoded values"),
person(given = "Daniela",
family = "de los Santos",
role = "ctb",
comment = "proposed improvements to default parameters"),
person(given = "Emily",
family = "Riederer",
role = "rev",
comment = "reviewed the package for rOpenSci, see https://github.com/ropensci/onboarding/issues/274"),
person(given = "Mark",
family = "Padgham",
role = "rev",
comment = "reviewed the package for rOpenSci, see https://github.com/ropensci/onboarding/issues/274"),
person(given = "Amanda",
family = "Dobbyn",
role = "rev",
comment = "reviewed a previous package that evolved into the current package for rOpenSci, see https://github.com/ropensci/onboarding/issues/217"),
person(given = "Jorge",
family = "Cimentada",
role = "rev",
comment = "reviewed a previous package that evolved into the current package for rOpenSci, see https://github.com/ropensci/onboarding/issues/217"),
person(family = "UN Comtrade",
role = "dtc"),
person(family = "The World Bank",
role = "dtc")
)
person("Mauricio", "Vargas", , "mavargas11@uc.cl", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0003-1017-7574")),
person("Joshua", "Kunst", role = "ctb",
comment = "contributed to different parts of the pre-release code"),
person("Alexey", "Kravchenko", role = "ctb",
comment = "reviewed 2021 version of the API"),
person("Emma", "Mendelsohn", role = "ctb",
comment = "updated the functions to take available years from the API instead of hardcoded values"),
person("Daniela", "de los Santos", role = "ctb",
comment = "proposed improvements to default parameters"),
person("Emily", "Riederer", role = "rev",
comment = "reviewed the package for rOpenSci, see https://github.com/ropensci/onboarding/issues/274"),
person("Mark", "Padgham", role = "rev",
comment = "reviewed the package for rOpenSci, see https://github.com/ropensci/onboarding/issues/274"),
person("Amanda", "Dobbyn", role = "rev",
comment = "reviewed a previous package that evolved into the current package for rOpenSci, see https://github.com/ropensci/onboarding/issues/217"),
person("Jorge", "Cimentada", role = "rev",
comment = "reviewed a previous package that evolved into the current package for rOpenSci, see https://github.com/ropensci/onboarding/issues/217"),
person(, "UN Comtrade", role = "dtc"),
person(, "The World Bank", role = "dtc")
)
Description: Access 'Open Trade Statistics' API from R to download
international trade data.
License: Apache License (>= 2)
URL: https://docs.ropensci.org/tradestatistics/
BugReports: https://github.com/ropensci/tradestatistics/issues/
Description: Access 'Open Trade Statistics' API from R to download international trade data.
License: Apache License (>= 2)
LazyData: TRUE
Depends:
R (>= 2.10)
Imports:
crul,
arrow,
memoise,
data.table,
digest
RoxygenNote: 7.2.0
digest,
jsonlite,
memoise,
utils
Suggests:
covr,
knitr,
rmarkdown,
tibble,
testthat (>= 2.1.0),
vcr,
covr
VignetteBuilder: knitr
tibble,
vcr
VignetteBuilder:
knitr
Encoding: UTF-8
Depends:
R (>= 2.10)
LazyData: TRUE
RoxygenNote: 7.2.3
2 changes: 1 addition & 1 deletion NAMESPACE
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export(ots_commodity_code)
export(ots_country_code)
export(ots_create_tidy_data)
export(ots_gdp_deflator_adjustment)
importFrom(arrow,read_parquet)
importFrom(crul,HttpClient)
importFrom(data.table,`:=`)
importFrom(data.table,fread)
Expand All @@ -13,6 +12,7 @@ importFrom(data.table,last)
importFrom(data.table,rbindlist)
importFrom(data.table,setnames)
importFrom(digest,digest)
importFrom(jsonlite,fromJSON)
importFrom(memoise,forget)
importFrom(memoise,memoise)
importFrom(utils,read.csv)
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# version 4.5

* Reflects changes in the API and therefore reads JSON data.
* Continues to use data.table for the internals and tibble to display the results nicely.
* Future versions will only use tibble but that would require effort.

# version 4.2

Updates
Expand Down
1 change: 0 additions & 1 deletion R/ots_create_tidy_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#' such as exports growth w/r to last year) between a \code{reporter}
#' and \code{partner} country.
#' @importFrom data.table `:=` rbindlist setnames
#' @importFrom arrow read_parquet
#' @importFrom crul HttpClient
#' @export
#' @examples
Expand Down
9 changes: 3 additions & 6 deletions R/ots_read_from_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' \code{JSON} data. The parameters here are passed from
#' \code{ots_create_tidy_data}.
#' @importFrom crul HttpClient
#' @importFrom jsonlite fromJSON
#' @keywords internal
ots_read_from_api <- function(year = NULL,
reporter_iso = NULL,
Expand Down Expand Up @@ -46,17 +47,13 @@ ots_read_from_api <- function(year = NULL,
}

message(sprintf("Downloading data for the combination %s...", combination))

if (!requireNamespace("arrow", quietly = TRUE)) {
stop("`arrow` must be installed for reading parquet data to work")
}

data <- try(read_parquet(resp$content))
data <- try(fromJSON(resp$parse(encoding = "UTF-8")))

if (!is.data.frame(data)) {
stop("It wasn't possible to obtain data. Provided this function tests your internet connection\nyou misspelled a reporter, partner or table, or there was a server problem. Please check and try again.")
}

return(data)
} else if (max_attempts == 0) {
# when attempts run out, stop with an error
Expand Down
Binary file removed R/sysdata.rda
Binary file not shown.
12 changes: 12 additions & 0 deletions dev/config_attachment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
path.n: NAMESPACE
path.d: DESCRIPTION
dir.r: R
dir.v: vignettes
dir.t: tests
extra.suggests: ~
pkg_ignore: ~
document: yes
normalize: yes
inside_rmd: no
must.exist: yes
check_if_suggests_is_installed: yes
175 changes: 14 additions & 161 deletions tests/fixtures/vcr_cassettes/chl_all_2002_yrp.yml

Large diffs are not rendered by default.

Loading

0 comments on commit ec04943

Please sign in to comment.