From c0949db233149dcf77859db95a7bc415ff0e9a65 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 10:38:57 +0800 Subject: [PATCH 01/41] Delete extra svg --- inst/logo.svg.2024_09_22_11_39_48.0.svg | 201 ------------------------ 1 file changed, 201 deletions(-) delete mode 100644 inst/logo.svg.2024_09_22_11_39_48.0.svg diff --git a/inst/logo.svg.2024_09_22_11_39_48.0.svg b/inst/logo.svg.2024_09_22_11_39_48.0.svg deleted file mode 100644 index 0d22154..0000000 --- a/inst/logo.svg.2024_09_22_11_39_48.0.svg +++ /dev/null @@ -1,201 +0,0 @@ - - - -abares - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - abaresabares2024-09-22Adam H. SparksSVG Repo, https://www.svgrepo.com/svg/172230/combine-harvester -CC BY-SA 4.0RHex Logo From 4f34f8cf1230b1e44580aa65565943b8ce459405 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 15:48:12 +0800 Subject: [PATCH 02/41] Clarify column renaming and reordering --- R/get_abares_trade.R | 5 +++-- R/get_abares_trade_regions.R | 3 ++- R/get_historical_forecast_database.R | 3 ++- R/get_historical_national_estimates.R | 5 ++--- R/get_historical_regional_estimates.R | 3 ++- R/get_historical_state_estimates.R | 3 ++- man/get_abares_trade.Rd | 3 ++- man/get_abares_trade_regions.Rd | 3 ++- man/get_historical_forecast_database.Rd | 3 ++- man/get_historical_national_estimates.Rd | 3 ++- man/get_historical_regional_estimates.Rd | 3 ++- man/get_historical_state_estimates.Rd | 3 ++- 12 files changed, 25 insertions(+), 15 deletions(-) diff --git a/R/get_abares_trade.R b/R/get_abares_trade.R index 339aa38..f735ace 100644 --- a/R/get_abares_trade.R +++ b/R/get_abares_trade.R @@ -3,7 +3,8 @@ #' Fetches and imports \acronym{ABARES} trade data. #' #' @note -#' Columns are renamed for consistency. +#' Columns are renamed for consistency with other \acronym{ABARES} products +#' serviced in this package using a snake_case format and ordered consistently. #' #' @param cache `Boolean` Cache the \acronym{ABARES} trade data after download #' using `tools::R_user_dir()` to identify the proper directory for storing @@ -60,7 +61,7 @@ get_abares_trade <- function(cache = TRUE) { } return(abares_trade) } else { - return(NULL) + return(invisible(NULL)) } } diff --git a/R/get_abares_trade_regions.R b/R/get_abares_trade_regions.R index f2c8567..d13d484 100644 --- a/R/get_abares_trade_regions.R +++ b/R/get_abares_trade_regions.R @@ -3,7 +3,8 @@ #' Fetches and imports \acronym{ABARES} trade regions data. #' #' @note -#' Columns are renamed for consistency in this package using lower case, snake_case format. +#' Columns are renamed for consistency with other \acronym{ABARES} products +#' serviced in this package using a snake_case format and ordered consistently. #' #' @param cache `Boolean` Cache the \acronym{ABARES} trade regions data after #' download using `tools::R_user_dir()` to identify the proper directory for diff --git a/R/get_historical_forecast_database.R b/R/get_historical_forecast_database.R index 82981eb..181a792 100644 --- a/R/get_historical_forecast_database.R +++ b/R/get_historical_forecast_database.R @@ -19,7 +19,8 @@ #' | Actual_Value | Actual outcome observed. Note that historical time series can be revised. Latest available data at time of update, including any revisions, are included in database. | #' #' @note -#' Columns are renamed for consistency. +#' Columns are renamed for consistency with other \acronym{ABARES} products +#' serviced in this package using a snake_case format and ordered consistently. #' #' @note #' The "Month_issued" column is converted from a character string to a numeric diff --git a/R/get_historical_national_estimates.R b/R/get_historical_national_estimates.R index 9ac0902..ad51cf6 100644 --- a/R/get_historical_national_estimates.R +++ b/R/get_historical_national_estimates.R @@ -1,10 +1,9 @@ - - #' Get Historical National Estimates from ABARES #' #' @note -#' Columns are renamed and reordered for consistency. +#' Columns are renamed for consistency with other \acronym{ABARES} products +#' serviced in this package using a snake_case format and ordered consistently. #' #' @return A [data.table::data.table] object with the `Variable` field as the #' `key`. diff --git a/R/get_historical_regional_estimates.R b/R/get_historical_regional_estimates.R index 16ab1da..c6c9484 100644 --- a/R/get_historical_regional_estimates.R +++ b/R/get_historical_regional_estimates.R @@ -2,7 +2,8 @@ #' Get Historical Regional Estimates from ABARES #' #' @note -#' Columns are renamed and reordered for consistency. +#' Columns are renamed for consistency with other \acronym{ABARES} products +#' serviced in this package using a snake_case format and ordered consistently. #' #' @return A [data.table::data.table] object with the `Variable` field as the #' `key`. diff --git a/R/get_historical_state_estimates.R b/R/get_historical_state_estimates.R index d0a3d84..f807512 100644 --- a/R/get_historical_state_estimates.R +++ b/R/get_historical_state_estimates.R @@ -2,7 +2,8 @@ #' Get Historical State Estimates from ABARES #' #' @note -#' Columns are renamed and reordered for consistency. +#' Columns are renamed for consistency with other \acronym{ABARES} products +#' serviced in this package using a snake_case format and ordered consistently. #' #' @return A [data.table::data.table] object with the `Variable` field as the #' `key`. diff --git a/man/get_abares_trade.Rd b/man/get_abares_trade.Rd index 64fb9af..615014f 100644 --- a/man/get_abares_trade.Rd +++ b/man/get_abares_trade.Rd @@ -23,7 +23,8 @@ A \CRANpkg{data.table} object of the \acronym{ABARES} trade data. Fetches and imports \acronym{ABARES} trade data. } \note{ -Columns are renamed for consistency. +Columns are renamed for consistency with other \acronym{ABARES} products +serviced in this package using a snake_case format and ordered consistently. } \examples{ \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} diff --git a/man/get_abares_trade_regions.Rd b/man/get_abares_trade_regions.Rd index 379cf85..b362006 100644 --- a/man/get_abares_trade_regions.Rd +++ b/man/get_abares_trade_regions.Rd @@ -23,7 +23,8 @@ A \CRANpkg{data.table} object of the \acronym{ABARES} trade data regions. Fetches and imports \acronym{ABARES} trade regions data. } \note{ -Columns are renamed for consistency in this package using lower case, snake_case format. +Columns are renamed for consistency with other \acronym{ABARES} products +serviced in this package using a snake_case format and ordered consistently. } \examples{ \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} diff --git a/man/get_historical_forecast_database.Rd b/man/get_historical_forecast_database.Rd index 9d724cc..7f72550 100644 --- a/man/get_historical_forecast_database.Rd +++ b/man/get_historical_forecast_database.Rd @@ -35,7 +35,8 @@ Get Historical Forecast Database From ABARES } } \note{ -Columns are renamed for consistency. +Columns are renamed for consistency with other \acronym{ABARES} products +serviced in this package using a snake_case format and ordered consistently. The "Month_issued" column is converted from a character string to a numeric value representing the month of year, \emph{e.g.}, "March" is converted to \code{3}. diff --git a/man/get_historical_national_estimates.Rd b/man/get_historical_national_estimates.Rd index e5e0e56..dd960a8 100644 --- a/man/get_historical_national_estimates.Rd +++ b/man/get_historical_national_estimates.Rd @@ -17,7 +17,8 @@ A \link[data.table:data.table]{data.table::data.table} object with the \code{Var Get Historical National Estimates from ABARES } \note{ -Columns are renamed and reordered for consistency. +Columns are renamed for consistency with other \acronym{ABARES} products +serviced in this package using a snake_case format and ordered consistently. } \examples{ \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} diff --git a/man/get_historical_regional_estimates.Rd b/man/get_historical_regional_estimates.Rd index 11e3c7c..37bf690 100644 --- a/man/get_historical_regional_estimates.Rd +++ b/man/get_historical_regional_estimates.Rd @@ -20,7 +20,8 @@ A \link[data.table:data.table]{data.table::data.table} object with the \code{Var Get Historical Regional Estimates from ABARES } \note{ -Columns are renamed and reordered for consistency. +Columns are renamed for consistency with other \acronym{ABARES} products +serviced in this package using a snake_case format and ordered consistently. } \examples{ \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} diff --git a/man/get_historical_state_estimates.Rd b/man/get_historical_state_estimates.Rd index 3faef92..4f7f7e0 100644 --- a/man/get_historical_state_estimates.Rd +++ b/man/get_historical_state_estimates.Rd @@ -20,7 +20,8 @@ A \link[data.table:data.table]{data.table::data.table} object with the \code{Var Get Historical State Estimates from ABARES } \note{ -Columns are renamed and reordered for consistency. +Columns are renamed for consistency with other \acronym{ABARES} products +serviced in this package using a snake_case format and ordered consistently. } \examples{ \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} From db5821e7028996b231b42d3737416ac45a5e7133 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 15:48:32 +0800 Subject: [PATCH 03/41] Simplify .retry_download() to actually work as intended with less lines --- R/internal_functions.R | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/R/internal_functions.R b/R/internal_functions.R index 9e0d40c..0cff21e 100644 --- a/R/internal_functions.R +++ b/R/internal_functions.R @@ -49,35 +49,12 @@ #' @keywords Internal #' @noRd -.retry_download <- function(url, - .f, - .max_tries = 3L, - .initial_delay = 1L) { - attempt <- 1 - success <- FALSE - - while (attempt <= .max_tries && !success) { - tryCatch({ - response <- httr2::request(base_url = url) |> - httr2::req_options(http_version = 2, timeout = 120L) |> - httr2::req_retry(max_tries = .max_tries) |> - httr2::req_perform() - - writeBin(response$body, con = .f) - success <- TRUE - }, error = function(e) { - if (attempt < .max_tries) { - delay <- .initial_delay * 2 ^ (attempt - 1) - cli::cli_alert( - "Download failed on attempt { attempt }. Retrying in { delay } seconds..." - ) - Sys.sleep(delay) - attempt <- attempt + 1 - } else { - cli::cli_abort( - "Download failed after { .max_tries } attempts.") - stop(e) - } - }) - } +.retry_download <- function(url, .f, .max_tries = 3L) { + tryCatch( + response <- httr2::request(base_url = url) |> + httr2::req_options(http_version = 2, timeout = 240L) |> + httr2::req_retry(max_tries = .max_tries) |> + httr2::req_perform(path = .f), + httr2_error = function(cnd) NULL + ) } From 1fd13484f141fd02b7a0439dcd0c99a5fe6ab1b2 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 15:49:49 +0800 Subject: [PATCH 04/41] use httptest2 and test .retry_download() --- tests/testthat/setup.R | 1 + tests/testthat/test-retry_download.R | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/testthat/setup.R create mode 100644 tests/testthat/test-retry_download.R diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 0000000..4c9cf1d --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1 @@ +library(httptest2) diff --git a/tests/testthat/test-retry_download.R b/tests/testthat/test-retry_download.R new file mode 100644 index 0000000..839e0af --- /dev/null +++ b/tests/testthat/test-retry_download.R @@ -0,0 +1,20 @@ + +mock_dir("test_retry_download", { + test_that(".retry_download works properly", { + skip_if_offline() + f <- file.path(tempdir(), "logo.svg") + url <- "https://raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/logo.svg" + expect_no_condition(.retry_download(url = url, .f = f)) + expect_no_condition(file.exists(f)) + }) +}) + +without_internet({ + test_that(".retry_download provides an error if no connection", { + f <- file.path(tempdir(), "logo.svg") + url <- "https://raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/logo.svg" + expect_error(.retry_download(url = url, .f = f, .max_tries = 2L), + regexp = "Download failed after 2 attempts.") + expect_no_condition(file.exists(f)) + }) +}) From 7ff50b69236867eecb754247d74ffc82385b4aa9 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 15:50:06 +0800 Subject: [PATCH 05/41] Fix tests!!! Tested wrong fn. --- tests/testthat/test-get_abares_trade.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-get_abares_trade.R b/tests/testthat/test-get_abares_trade.R index c04e679..ba9cfec 100644 --- a/tests/testthat/test-get_abares_trade.R +++ b/tests/testthat/test-get_abares_trade.R @@ -58,7 +58,7 @@ test_that("get_abares_trade doesn't cache", { test_that("get_abares_trade skips downloading if still in tempdir()", { skip_if_offline() skip_on_ci() - x <- .check_existing_trade_regions(cache = FALSE) + x <- .check_existing_trade(cache = FALSE) expect_s3_class(x, c("data.table", "data.frame")) }) @@ -81,7 +81,7 @@ test_that("get_abares_trade caches", { test_that("get_abares_trade skips downloading if cache is available", { skip_if_offline() skip_on_ci() - x <- .check_existing_trade_regions(cache = TRUE) + x <- .check_existing_trade(cache = TRUE) expect_s3_class(x, c("data.table", "data.frame")) }) From 11f2d469254efea7b43020f20322345d61fdc5e6 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 15:50:19 +0800 Subject: [PATCH 06/41] adds rlang and httptest2 --- DESCRIPTION | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index f333868..c19f5fc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,6 +24,7 @@ Imports: openxlsx2, purrr, readtext, + rlang, sf, stars, stringr, @@ -31,6 +32,7 @@ Imports: tidync, withr Suggests: + httptest2, knitr, pander, rmarkdown, From c8e04bd7e70a57f97de5fb20c82738382587c391 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 16:11:42 +0800 Subject: [PATCH 07/41] test in parallel --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index c19f5fc..85132b0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,6 +44,7 @@ VignetteBuilder: Config/roxyglobals/filename: globals.R Config/roxyglobals/unique: FALSE Config/testthat/edition: 3 +Config/testthat/parallel: true Encoding: UTF-8 Language: en-US Roxygen: list(markdown = TRUE, roclets = c("collate", "namespace", "rd", From 0a9ba825d3a25734d3e649d606fdc81ad3c73d84 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 18:43:41 +0800 Subject: [PATCH 08/41] completely rewrite download function to use tryCatch and {brio} --- R/internal_functions.R | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/R/internal_functions.R b/R/internal_functions.R index 0cff21e..6169586 100644 --- a/R/internal_functions.R +++ b/R/internal_functions.R @@ -50,11 +50,22 @@ #' @noRd .retry_download <- function(url, .f, .max_tries = 3L) { - tryCatch( - response <- httr2::request(base_url = url) |> - httr2::req_options(http_version = 2, timeout = 240L) |> + tryCatch({ + resp <- httr2::request(base_url = url) |> + httr2::req_options(http_version = 2, timeout = 500L) |> httr2::req_retry(max_tries = .max_tries) |> - httr2::req_perform(path = .f), - httr2_error = function(cnd) NULL - ) + httr2::req_perform() + }, error = function(e) { + cli::cli_abort("There was an error with this download, please retry.", + call = rlang::caller_env()) + }) + if (httr2::resp_content_type(resp) == "application/x-zip-compressed") { + resp |> + httr2::resp_body_raw() |> + brio::write_file_raw(path = .f) + } else { + resp |> + httr2::resp_body_string() |> + brio::write_file(path = .f) + } } From 065101860ee88eb3b8af74b0ceea7cf7baf2445f Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 18:44:16 +0800 Subject: [PATCH 09/41] use CITATION file for test and mock download --- tests/testthat/test-retry_download.R | 15 +++++++-------- .../read.abares/refs/heads/main/inst/CITATION.txt | 10 ++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 tests/testthat/test_retry_download/raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION.txt diff --git a/tests/testthat/test-retry_download.R b/tests/testthat/test-retry_download.R index 839e0af..f5226dc 100644 --- a/tests/testthat/test-retry_download.R +++ b/tests/testthat/test-retry_download.R @@ -1,20 +1,19 @@ -mock_dir("test_retry_download", { +with_mock_dir("test_retry_download", { test_that(".retry_download works properly", { - skip_if_offline() - f <- file.path(tempdir(), "logo.svg") - url <- "https://raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/logo.svg" - expect_no_condition(.retry_download(url = url, .f = f)) + f <- file.path(tempdir(), "CITATION") + url <- "https://raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION" + .retry_download(url = url, .f = f) expect_no_condition(file.exists(f)) }) }) without_internet({ test_that(".retry_download provides an error if no connection", { - f <- file.path(tempdir(), "logo.svg") - url <- "https://raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/logo.svg" + f <- file.path(tempdir(), "CITATION") + url <- "https://raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION" expect_error(.retry_download(url = url, .f = f, .max_tries = 2L), - regexp = "Download failed after 2 attempts.") + regexp = "There was an error with this download, please retry.") expect_no_condition(file.exists(f)) }) }) diff --git a/tests/testthat/test_retry_download/raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION.txt b/tests/testthat/test_retry_download/raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION.txt new file mode 100644 index 0000000..84d5533 --- /dev/null +++ b/tests/testthat/test_retry_download/raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION.txt @@ -0,0 +1,10 @@ + +bibentry( + bibtype = "Manual", + title = "{read.abares}: Simple downloading and importing of ABARES Data", + author = c( + person("Adam H.", "Sparks") + ), + year = sub("-.*", "", meta$Date), + note = sprintf("R package version %s", meta$Version), + url = "https://adamhsparks.codeberg.page/read.abares/") From f9691b18fdcc2c56b91f21e04511a915ac86f008 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 18:44:40 +0800 Subject: [PATCH 10/41] try fixing bugs in get_agfd() --- R/get_agfd.R | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/R/get_agfd.R b/R/get_agfd.R index f00b011..e6f4b21 100644 --- a/R/get_agfd.R +++ b/R/get_agfd.R @@ -88,7 +88,7 @@ get_agfd <- function(fixed_prices = TRUE, cache = TRUE) { if (!dir.exists(agfd_nc_dir)) { # if caching is enabled but the {read.abares} cache dir doesn't exist, create it if (cache) { - dir.create(download_dir, recursive = TRUE) + dir.create(agfd_nc_dir, recursive = TRUE) } url <- data.table::fifelse( @@ -100,10 +100,21 @@ get_agfd <- function(fixed_prices = TRUE, cache = TRUE) { .retry_download(url = url, .f = download_file) + tryCatch({ withr::with_dir(download_dir, utils::unzip(zipfile = download_file, exdir = download_dir)) - unlink(download_file) + }, + error = function(e) { + unlink(download_file) + cli::cli_abort("There was an issue with the downloaded file. I've deleted + this bad version of the downloaded file, please retry.", + call = rlang::caller_env()) + }, + finally = { + # clean up on success! + unlink(download_file) + }) } agfd_nc <- list.files(agfd_nc_dir, full.names = TRUE) From d4313589480768bfc1547840f3175f4911c0ecef Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 18:45:26 +0800 Subject: [PATCH 11/41] add references and sources to trade regions --- R/get_abares_trade_regions.R | 6 ++++-- man/get_abares_trade_regions.Rd | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/R/get_abares_trade_regions.R b/R/get_abares_trade_regions.R index d13d484..ff94313 100644 --- a/R/get_abares_trade_regions.R +++ b/R/get_abares_trade_regions.R @@ -17,9 +17,11 @@ #' #' trade_regions #' -#' @return A \CRANpkg{data.table} object of the \acronym{ABARES} trade data regions. +#' @return A \CRANpkg{data.table} object of the \acronym{ABARES} trade data +#' regions. #' @family Trade -#' @source +#' @referencs +#' @source #' @autoglobal #' @export diff --git a/man/get_abares_trade_regions.Rd b/man/get_abares_trade_regions.Rd index b362006..ac58e88 100644 --- a/man/get_abares_trade_regions.Rd +++ b/man/get_abares_trade_regions.Rd @@ -4,7 +4,7 @@ \alias{get_abares_trade_regions} \title{Get ABARES Trade Data Regions From the ABARES Trade Dashboard} \source{ -\url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1033841/0} +\url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1033841/2} } \usage{ get_abares_trade_regions(cache = TRUE) @@ -17,7 +17,8 @@ the files locally as a native \R object. If \code{FALSE}, this function uses \code{tempdir()} and the files are deleted upon closing of the \R session.} } \value{ -A \CRANpkg{data.table} object of the \acronym{ABARES} trade data regions. +A \CRANpkg{data.table} object of the \acronym{ABARES} trade data +regions. } \description{ Fetches and imports \acronym{ABARES} trade regions data. From e7cf24c667e03af50614bfe130b58d958a2aaa80 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 18:45:37 +0800 Subject: [PATCH 12/41] use {brio} to write files --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 85132b0..5f90766 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,6 +17,7 @@ BugReports: https://github.com/adamhsparks/read.abares/issues Depends: R (>= 4.1.0) Imports: + brio, cli, data.table, httr2, From 63a0d184b966e9fcc608d012849891668cbda8f9 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 21:14:20 +0800 Subject: [PATCH 13/41] Fix references field in get_abares_trade_regions() --- R/get_abares_trade_regions.R | 2 +- man/get_abares_trade_regions.Rd | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/R/get_abares_trade_regions.R b/R/get_abares_trade_regions.R index ff94313..19f3d83 100644 --- a/R/get_abares_trade_regions.R +++ b/R/get_abares_trade_regions.R @@ -20,7 +20,7 @@ #' @return A \CRANpkg{data.table} object of the \acronym{ABARES} trade data #' regions. #' @family Trade -#' @referencs +#' @references #' @source #' @autoglobal #' @export diff --git a/man/get_abares_trade_regions.Rd b/man/get_abares_trade_regions.Rd index ac58e88..67558b4 100644 --- a/man/get_abares_trade_regions.Rd +++ b/man/get_abares_trade_regions.Rd @@ -34,6 +34,9 @@ trade_regions <- get_abares_trade_regions() trade_regions \dontshow{\}) # examplesIf} } +\references{ +\url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1033841/0} +} \seealso{ Other Trade: \code{\link{get_abares_trade}()} From cba882ee265519d99592ae4a55a4cbfdc8308a3f Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 21:27:23 +0800 Subject: [PATCH 14/41] update Wordlist --- inst/WORDLIST | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/WORDLIST b/inst/WORDLIST index 3d0a25c..aa9d25c 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -15,6 +15,7 @@ Codecov DAFF DLWC DOI +Geopackage Gridded ISSN Landforms From a9390f62b7684c2a8c1b22eea9aa59c3665a5254 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 21:27:45 +0800 Subject: [PATCH 15/41] don't wrap test w/ mocking dir, causes errors on check --- tests/testthat/test-retry_download.R | 19 ++++++++++--------- .../refs/heads/main/inst/CITATION.txt | 10 ---------- 2 files changed, 10 insertions(+), 19 deletions(-) delete mode 100644 tests/testthat/test_retry_download/raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION.txt diff --git a/tests/testthat/test-retry_download.R b/tests/testthat/test-retry_download.R index f5226dc..231f1a4 100644 --- a/tests/testthat/test-retry_download.R +++ b/tests/testthat/test-retry_download.R @@ -1,19 +1,20 @@ -with_mock_dir("test_retry_download", { - test_that(".retry_download works properly", { - f <- file.path(tempdir(), "CITATION") - url <- "https://raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION" - .retry_download(url = url, .f = f) - expect_no_condition(file.exists(f)) - }) +test_that(".retry_download works properly", { + f <- file.path(tempdir(), "CITATION") + url <- "https://raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION" + .retry_download(url = url, .f = f) + expect_no_condition(file.exists(f)) }) without_internet({ test_that(".retry_download provides an error if no connection", { f <- file.path(tempdir(), "CITATION") url <- "https://raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION" - expect_error(.retry_download(url = url, .f = f, .max_tries = 2L), - regexp = "There was an error with this download, please retry.") + expect_error(.retry_download( + url = url, + .f = f, + .max_tries = 2L + ), regexp = "There was an error with this download, please retry.") expect_no_condition(file.exists(f)) }) }) diff --git a/tests/testthat/test_retry_download/raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION.txt b/tests/testthat/test_retry_download/raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION.txt deleted file mode 100644 index 84d5533..0000000 --- a/tests/testthat/test_retry_download/raw.githubusercontent.com/adamhsparks/read.abares/refs/heads/main/inst/CITATION.txt +++ /dev/null @@ -1,10 +0,0 @@ - -bibentry( - bibtype = "Manual", - title = "{read.abares}: Simple downloading and importing of ABARES Data", - author = c( - person("Adam H.", "Sparks") - ), - year = sub("-.*", "", meta$Date), - note = sprintf("R package version %s", meta$Version), - url = "https://adamhsparks.codeberg.page/read.abares/") From 6d5e2362bf06d3a99c503e74e6733d44c480aced Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sun, 1 Dec 2024 21:34:46 +0800 Subject: [PATCH 16/41] use httr2 caching --- R/internal_functions.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/internal_functions.R b/R/internal_functions.R index 6169586..2384c02 100644 --- a/R/internal_functions.R +++ b/R/internal_functions.R @@ -28,8 +28,8 @@ #' Use httr2 to Fetch a File With Retries #' -#' Retries to download the requested resource five times before stopping. Then -#' saves the resource in the `tempdir()` for importing. +#' Retries to download the requested resource before stopping. Uses {httr2} to +#' cache in-session results in the `tempdir()`. #' #' @param url `Character` The URL being requested #' @param .f `Character` A filepath to be written to local storage @@ -54,7 +54,8 @@ resp <- httr2::request(base_url = url) |> httr2::req_options(http_version = 2, timeout = 500L) |> httr2::req_retry(max_tries = .max_tries) |> - httr2::req_perform() + httr2::req_perform() |> + httr2::req_cache(path = tempdir()) }, error = function(e) { cli::cli_abort("There was an error with this download, please retry.", call = rlang::caller_env()) From 8e93ccfceb57c65e65c397279f2d958dd20accbf Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Mon, 2 Dec 2024 07:45:45 +0800 Subject: [PATCH 17/41] fix httr2 caching --- R/internal_functions.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/internal_functions.R b/R/internal_functions.R index 2384c02..c96b615 100644 --- a/R/internal_functions.R +++ b/R/internal_functions.R @@ -54,8 +54,10 @@ resp <- httr2::request(base_url = url) |> httr2::req_options(http_version = 2, timeout = 500L) |> httr2::req_retry(max_tries = .max_tries) |> - httr2::req_perform() |> - httr2::req_cache(path = tempdir()) + httr2::req_progress() |> + httr2::req_cache(path = tempdir()) |> + httr2::req_perform() + }, error = function(e) { cli::cli_abort("There was an error with this download, please retry.", call = rlang::caller_env()) From e389db10aa58223590ff3aed36508b9b623abc69 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Mon, 2 Dec 2024 21:19:49 +0800 Subject: [PATCH 18/41] Update --- R/get_abares_trade.R | 36 ++------------- R/get_soil_thickness.R | 57 ++++-------------------- R/internal_functions.R | 14 +++--- tests/testthat/test-get_abares_trade.R | 16 +------ tests/testthat/test-get_soil_thickness.R | 28 ++---------- 5 files changed, 20 insertions(+), 131 deletions(-) diff --git a/R/get_abares_trade.R b/R/get_abares_trade.R index f735ace..16fdcc2 100644 --- a/R/get_abares_trade.R +++ b/R/get_abares_trade.R @@ -25,43 +25,13 @@ #' @export get_abares_trade <- function(cache = TRUE) { - trade <- .check_existing_trade(cache) - if (!is.null(trade)) { - return(trade) - } else { - return(.download_abares_trade(cache)) - } -} - -#' Check for Pre-existing File Before Downloading -#' -#' Checks the user cache first, then `tempdir()` for the files before -#' returning a `NULL` value. If `cache == TRUE` and the file is not in the user -#' cache, but is in `tempdir()`, it is saved to the cache before being returned -#' in the current session. -#' -#' -#' @return A \CRANpkg{data.table} object of the \acronym{ABARES} trade data -#' @noRd -#' @autoglobal -#' @keywords Internal - -.check_existing_trade <- function(cache) { abares_trade_rds <- file.path(.find_user_cache(), "abares_trade_dir/abares_trade.rds") - tmp_csv <- file.path(tempdir(), "abares_trade.zip") if (file.exists(abares_trade_rds)) { return(readRDS(abares_trade_rds)) - } else if (file.exists(tmp_csv)) { - abares_trade <- data.table::fread(tmp_csv) - if (cache) { - dir.create(dirname(abares_trade_rds), recursive = TRUE) - saveRDS(abares_trade, file = abares_trade_rds) - } - return(abares_trade) } else { - return(invisible(NULL)) + return(.download_abares_trade(cache)) } } @@ -82,7 +52,7 @@ get_abares_trade <- function(cache = TRUE) { .download_abares_trade <- function(cache) { # if you make it this far, the cached file doesn't exist, so we need to # download it either to `tempdir()` and dispose or cache it for later. - cached_zip <- file.path(.find_user_cache(), "abares_trade_dir/trade.zip") + cached_zip <- file.path(.find_user_cache(), "abares_trade_dir/trade.csv") tmp_zip <- file.path(file.path(tempdir(), "abares_trade.zip")) trade_zip <- data.table::fifelse(cache, cached_zip, tmp_zip) abares_trade_dir <- dirname(trade_zip) @@ -94,7 +64,7 @@ get_abares_trade <- function(cache = TRUE) { } .retry_download( - "https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1033841/1", + url = "https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1033841/1", .f = trade_zip) abares_trade <- data.table::fread(trade_zip) diff --git a/R/get_soil_thickness.R b/R/get_soil_thickness.R index b91b0d7..17474d4 100644 --- a/R/get_soil_thickness.R +++ b/R/get_soil_thickness.R @@ -34,55 +34,13 @@ #' @export get_soil_thickness <- function(cache = TRUE) { - soil_thick <- .check_existing_soil(cache) - if (is.null(soil_thick)) { - .download_soil_thickness(cache) - soil_thick <- .create_soil_thickness_list( - soil_dir = file.path(tempdir(), "soil_thickness_dir")) - return(soil_thick) + thpk_1_cache <- file.path(.find_user_cache(), "soil_thickness_dir/thpk_1") + if (file.exists(thpk_1_cache)) { + return(.create_soil_thickness_list(dirname(thpk_1_cache))) } else { - return(soil_thick) - } -} - -#' Check for Pre-existing File Before Downloading -#' -#' Checks the user cache first, then `tempdir()` for the files before -#' returning a `NULL` value. If `cache == TRUE` and the file is not in the user -#' cache, but is in `tempdir()`, it is saved to the cache before being returned -#' in the current session. -#' -#' -#' @return A `read.abares.soil.thickness` object, which is a named `list` with -#' the file path of the resulting \acronym{ESRI} Grid file and text file of -#' metadata -#' @noRd -#' @autoglobal -#' @keywords Internal - -.check_existing_soil <- function(cache) { - - cache_grd <- file.path(.find_user_cache(), "soil_thickness_dir/thpk_1") - thpk_1_cache <- dirname(cache_grd) - tmp_grd <- file.path(tempdir(), "soil_thickness_dir/thpk_1") - - if (file.exists(cache_grd)) { - soil_dir <- dirname(cache_grd) - return(.create_soil_thickness_list(soil_dir)) - } else if (file.exists(tmp_grd)) { - soil_dir <- dirname(tmp_grd) - soil_thickness <- .create_soil_thickness_list(soil_dir) - if (cache && !dir.exists(thpk_1_cache)) { - dir.create(thpk_1_cache, recursive = TRUE) - file.copy( - from = dirname(tmp_grd), - to = thpk_1_cache, - recursive = TRUE - ) - } - return(soil_thickness) - } else { - return(NULL) + .download_soil_thickness(cache) + return(.create_soil_thickness_list(soil_dir = file.path(tempdir(), + "soil_thickness_dir"))) } } @@ -192,7 +150,8 @@ print.read.abares.soil.thickness.files <- function(x, ...) { Use Limitation: This dataset is bound by the requirements set down by the National Land & Water Resources Audit") cli::cli_text("To see the full metadata, call - {.fn print_soil_thickness_metadata} in your R session.") + {.fn print_soil_thickness_metadata} on a soil thickness object in your R + session.") cat("\n") invisible(x) } diff --git a/R/internal_functions.R b/R/internal_functions.R index c96b615..0c5fd6a 100644 --- a/R/internal_functions.R +++ b/R/internal_functions.R @@ -28,8 +28,8 @@ #' Use httr2 to Fetch a File With Retries #' -#' Retries to download the requested resource before stopping. Uses {httr2} to -#' cache in-session results in the `tempdir()`. +#' Retries to download the requested resource before stopping. Uses +#' \CRANpkg{httr2} to cache in-session results in the `tempdir()`. #' #' @param url `Character` The URL being requested #' @param .f `Character` A filepath to be written to local storage @@ -54,21 +54,17 @@ resp <- httr2::request(base_url = url) |> httr2::req_options(http_version = 2, timeout = 500L) |> httr2::req_retry(max_tries = .max_tries) |> - httr2::req_progress() |> httr2::req_cache(path = tempdir()) |> + httr2::req_progress() |> httr2::req_perform() }, error = function(e) { cli::cli_abort("There was an error with this download, please retry.", call = rlang::caller_env()) }) - if (httr2::resp_content_type(resp) == "application/x-zip-compressed") { + + # save the file to be imported into the R session. resp |> httr2::resp_body_raw() |> brio::write_file_raw(path = .f) - } else { - resp |> - httr2::resp_body_string() |> - brio::write_file(path = .f) - } } diff --git a/tests/testthat/test-get_abares_trade.R b/tests/testthat/test-get_abares_trade.R index ba9cfec..4f3387d 100644 --- a/tests/testthat/test-get_abares_trade.R +++ b/tests/testthat/test-get_abares_trade.R @@ -55,13 +55,6 @@ test_that("get_abares_trade doesn't cache", { )) }) -test_that("get_abares_trade skips downloading if still in tempdir()", { - skip_if_offline() - skip_on_ci() - x <- .check_existing_trade(cache = FALSE) - expect_s3_class(x, c("data.table", "data.frame")) -}) - # with caching ---- test_that("get_abares_trade caches", { @@ -74,15 +67,8 @@ test_that("get_abares_trade caches", { file.path(.find_user_cache(), "abares_trade_dir/abares_trade.rds") )) expect_true(!file.exists( - file.path(.find_user_cache(), "abares_trade_dir/abares_trade.csv") + file.path(.find_user_cache(), "abares_trade_dir/abares_trade.zip") )) }) -test_that("get_abares_trade skips downloading if cache is available", { - skip_if_offline() - skip_on_ci() - x <- .check_existing_trade(cache = TRUE) - expect_s3_class(x, c("data.table", "data.frame")) -}) - withr::deferred_run() diff --git a/tests/testthat/test-get_soil_thickness.R b/tests/testthat/test-get_soil_thickness.R index 0cde1f0..f5e489a 100644 --- a/tests/testthat/test-get_soil_thickness.R +++ b/tests/testthat/test-get_soil_thickness.R @@ -16,13 +16,6 @@ test_that("get_soil_thickness doesn't cache", { ))) }) -test_that("get_soil_thickness skips downloading if still in tempdir()", { - skip_if_offline() - skip_on_ci() - x <- .check_existing_soil(cache = FALSE) - expect_s3_class(x, c("read.abares.soil.thickness", "list")) -}) - withr::deferred_run() # with caching enabled after is was not initially enabled ---- @@ -39,13 +32,6 @@ test_that("get_soil_thickness caches", { ))) }) -test_that("get_soil_thickness skips downloading if cache is available", { - skip_if_offline() - skip_on_ci() - x <- .check_existing_soil(cache = TRUE) - expect_s3_class(x, c("read.abares.soil.thickness", "list")) -}) - test_that("get_soil_thickness does cache", { skip_if_offline() skip_on_ci() @@ -59,13 +45,6 @@ test_that("get_soil_thickness does cache", { ))) }) -test_that("get_soil_thickness skips downloading if still in tempdir()", { - skip_if_offline() - skip_on_ci() - x <- .check_existing_soil(cache = TRUE) - expect_s3_class(x, c("read.abares.soil.thickness", "list")) -}) - test_that("print.read.abares.thickness.files prints metadata", { skip_if_offline() skip_on_ci() @@ -100,10 +79,9 @@ test_that("print.read.abares.thickness.files prints metadata", { Use Limitation: This dataset is bound by the requirements set down by the National Land & Water Resources Audit" ) - cli::cli_text( - "To see the full metadata, call - {.fn print_soil_thickness_metadata} in your R session." - ) + cli::cli_text("To see the full metadata, call + {.fn print_soil_thickness_metadata} on a soil thickness object in your R + session.") cat("\n") } print_out <- capture.output(out_text()) From 8c34adfb8d725cbb996dda424912c7f54b711994 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Mon, 2 Dec 2024 21:20:20 +0800 Subject: [PATCH 19/41] Update some of the documentation --- R/read_soil_thickness_stars.R | 6 +++--- man/read_soil_thickness_stars.Rd | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/read_soil_thickness_stars.R b/R/read_soil_thickness_stars.R index a756753..912e105 100644 --- a/R/read_soil_thickness_stars.R +++ b/R/read_soil_thickness_stars.R @@ -2,10 +2,10 @@ #' Read Soil Thickness File With stars #' #' Read Soil Thickness for Australian Areas of Intensive Agriculture of Layer 1 -#' data as a [stars] object. +#' data as a \CRANpkg{stars} object. #' -#' @param files An \pkg{read.abares} `read.abares.soil.thickness` object, a `list` that -#' contains the \acronym{ESRI} grid file to import +#' @param files An \pkg{read.abares} `read.abares.soil.thickness` object, a +#' `list` that contains the \acronym{ESRI} grid file to import #' @return a [stars] object of the Soil Thickness for Australian Areas of #' Intensive Agriculture of Layer 1 #' diff --git a/man/read_soil_thickness_stars.Rd b/man/read_soil_thickness_stars.Rd index f3a9bc1..eee47ed 100644 --- a/man/read_soil_thickness_stars.Rd +++ b/man/read_soil_thickness_stars.Rd @@ -7,8 +7,8 @@ read_soil_thickness_stars(files) } \arguments{ -\item{files}{An \pkg{read.abares} \code{read.abares.soil.thickness} object, a \code{list} that -contains the \acronym{ESRI} grid file to import} +\item{files}{An \pkg{read.abares} \code{read.abares.soil.thickness} object, a +\code{list} that contains the \acronym{ESRI} grid file to import} } \value{ a \link{stars} object of the Soil Thickness for Australian Areas of @@ -16,7 +16,7 @@ Intensive Agriculture of Layer 1 } \description{ Read Soil Thickness for Australian Areas of Intensive Agriculture of Layer 1 -data as a \link{stars} object. +data as a \CRANpkg{stars} object. } \examples{ \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} From e39fb4b47fa88d8128740ec47df753b7bda0d9d1 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 07:43:43 +0800 Subject: [PATCH 20/41] increase timeout, remove tryCatch rely on httr2 error --- R/internal_functions.R | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/R/internal_functions.R b/R/internal_functions.R index 0c5fd6a..207ffd4 100644 --- a/R/internal_functions.R +++ b/R/internal_functions.R @@ -50,21 +50,12 @@ #' @noRd .retry_download <- function(url, .f, .max_tries = 3L) { - tryCatch({ - resp <- httr2::request(base_url = url) |> - httr2::req_options(http_version = 2, timeout = 500L) |> - httr2::req_retry(max_tries = .max_tries) |> - httr2::req_cache(path = tempdir()) |> - httr2::req_progress() |> - httr2::req_perform() - - }, error = function(e) { - cli::cli_abort("There was an error with this download, please retry.", - call = rlang::caller_env()) - }) - - # save the file to be imported into the R session. - resp |> - httr2::resp_body_raw() |> - brio::write_file_raw(path = .f) + httr2::request(base_url = url) |> + httr2::req_options(http_version = 2, timeout = 2000L) |> + httr2::req_retry(max_tries = .max_tries) |> + httr2::req_cache(path = tempdir()) |> + httr2::req_progress() |> + httr2::req_perform() |> + httr2::resp_body_raw() |> + brio::write_file_raw(path = .f) } From 6aac6f6f8ad2a1f0d4be2de17a01912a7c1fe6db Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 19:51:42 +0800 Subject: [PATCH 21/41] Update links and add source to documentation for estimates --- R/get_estimates_by_size.R | 5 +++-- R/get_historical_national_estimates.R | 3 ++- R/get_historical_regional_estimates.R | 5 +++-- man/get_historical_national_estimates.Rd | 3 +++ man/get_historical_regional_estimates.Rd | 5 ++++- man/get_historical_state_estimates.Rd | 5 ++++- tests/testthat/test-get_estimates_by_size.R | 2 +- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/R/get_estimates_by_size.R b/R/get_estimates_by_size.R index fe1427d..23951fa 100644 --- a/R/get_estimates_by_size.R +++ b/R/get_estimates_by_size.R @@ -6,7 +6,8 @@ #' #' @return A [data.table::data.table] object with the `Variable` field as the #' `key`. -#' @source +#' @references +#' @source #' @autoglobal #' @family Estimates #' @export @@ -22,7 +23,7 @@ get_estimates_by_size <- get_est_by_size <- function() { f <- file.path(tempdir(), "fdp-beta-performance-by-size.csv") .retry_download( - "https://www.agriculture.gov.au/sites/default/files/documents/fdp-beta-performance-by-size.csv", + "https://www.agriculture.gov.au/sites/default/files/documents/fdp-performance-by-size.csv", .f = f) x <- data.table::fread(f) diff --git a/R/get_historical_national_estimates.R b/R/get_historical_national_estimates.R index ad51cf6..27e650d 100644 --- a/R/get_historical_national_estimates.R +++ b/R/get_historical_national_estimates.R @@ -10,6 +10,7 @@ #' @autoglobal #' @family Estimates #' @references +#' @source #' @export #' @examplesIf interactive() #' @@ -23,7 +24,7 @@ get_historical_national_estimates <- function() { f <- file.path(tempdir(), "fdp-beta-national-historical.csv") .retry_download( - "https://www.agriculture.gov.au/sites/default/files/documents/fdp-beta-national-historical.csv", + "https://www.agriculture.gov.au/sites/default/files/documents/fdp-national-historical.csv", .f = f) x <- data.table::fread(f) diff --git a/R/get_historical_regional_estimates.R b/R/get_historical_regional_estimates.R index c6c9484..3fcf93a 100644 --- a/R/get_historical_regional_estimates.R +++ b/R/get_historical_regional_estimates.R @@ -9,7 +9,8 @@ #' `key`. #' @autoglobal #' @family Estimates -#' @source +#' @references +#' @source #' @export #' @examplesIf interactive() #' get_historical_regional_estimates() @@ -22,7 +23,7 @@ get_historical_regional_estimates <- get_hist_reg_est <- function() { f <- file.path(tempdir(), "fdp-beta-regional-historical.csv") .retry_download( - "https://www.agriculture.gov.au/sites/default/files/documents/fdp-beta-regional-historical.csv", + "https://www.agriculture.gov.au/sites/default/files/documents/fdp-regional-historical.csv", .f = f) x <- data.table::fread(f) diff --git a/man/get_historical_national_estimates.Rd b/man/get_historical_national_estimates.Rd index dd960a8..3145e3e 100644 --- a/man/get_historical_national_estimates.Rd +++ b/man/get_historical_national_estimates.Rd @@ -4,6 +4,9 @@ \alias{get_historical_national_estimates} \alias{get_hist_nat_est} \title{Get Historical National Estimates from ABARES} +\source{ +\url{https://www.agriculture.gov.au/sites/default/files/documents/fdp-national-historical.csv} +} \usage{ get_historical_national_estimates() diff --git a/man/get_historical_regional_estimates.Rd b/man/get_historical_regional_estimates.Rd index 37bf690..a5f41ea 100644 --- a/man/get_historical_regional_estimates.Rd +++ b/man/get_historical_regional_estimates.Rd @@ -5,7 +5,7 @@ \alias{get_hist_reg_est} \title{Get Historical Regional Estimates from ABARES} \source{ -\url{https://www.agriculture.gov.au/abares/data/farm-data-portal#data-download} +\url{https://www.agriculture.gov.au/sites/default/files/documents/fdp-regional-historical.csv} } \usage{ get_historical_regional_estimates() @@ -31,6 +31,9 @@ serviced in this package using a snake_case format and ordered consistently. get_hist_reg_est() \dontshow{\}) # examplesIf} } +\references{ +\url{https://www.agriculture.gov.au/abares/data/farm-data-portal#data-download} +} \seealso{ Other Estimates: \code{\link{get_estimates_by_performance_category}()}, diff --git a/man/get_historical_state_estimates.Rd b/man/get_historical_state_estimates.Rd index 4f7f7e0..7e64f7c 100644 --- a/man/get_historical_state_estimates.Rd +++ b/man/get_historical_state_estimates.Rd @@ -5,7 +5,7 @@ \alias{get_hist_sta_est} \title{Get Historical State Estimates from ABARES} \source{ -\url{https://www.agriculture.gov.au/abares/data/farm-data-portal#data-download} +\url{https://www.agriculture.gov.au/sites/default/files/documents/fdp-state-historical.csv} } \usage{ get_historical_state_estimates() @@ -31,6 +31,9 @@ serviced in this package using a snake_case format and ordered consistently. get_hist_sta_est() \dontshow{\}) # examplesIf} } +\references{ +\url{https://www.agriculture.gov.au/abares/data/farm-data-portal#data-download} +} \seealso{ Other Estimates: \code{\link{get_estimates_by_performance_category}()}, diff --git a/tests/testthat/test-get_estimates_by_size.R b/tests/testthat/test-get_estimates_by_size.R index 031dccb..7ec27d5 100644 --- a/tests/testthat/test-get_estimates_by_size.R +++ b/tests/testthat/test-get_estimates_by_size.R @@ -13,7 +13,7 @@ test_that("get_estimates_by_size works", { Size = "character", Industry = "character", Value = "double", - RSE = "integer" + RSE = "double" ) ) }) From 5403abc04e28e4618060cc43698d029da367b070 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 19:51:57 +0800 Subject: [PATCH 22/41] Simplify downloading of AGFD files --- R/get_agfd.R | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/R/get_agfd.R b/R/get_agfd.R index e6f4b21..a55fcfc 100644 --- a/R/get_agfd.R +++ b/R/get_agfd.R @@ -69,10 +69,11 @@ #' @autoglobal #' @export -get_agfd <- function(fixed_prices = TRUE, cache = TRUE) { +get_agfd <- function(fixed_prices = TRUE, + cache = TRUE) { download_file <- data.table::fifelse(cache, - file.path(.find_user_cache(), "agfd.zip"), - file.path(file.path(tempdir(), "agfd.zip"))) + file.path(.find_user_cache(), "agfd.zip"), + file.path(file.path(tempdir(), "agfd.zip"))) # this is where the zip file is downloaded download_dir <- dirname(download_file) @@ -97,26 +98,20 @@ get_agfd <- function(fixed_prices = TRUE, cache = TRUE) { "https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1036161/2" ) - .retry_download(url = url, - .f = download_file) + .retry_download(url = url, .f = download_file) tryCatch({ - withr::with_dir(download_dir, - utils::unzip(zipfile = download_file, - exdir = download_dir)) - }, - error = function(e) { - unlink(download_file) - cli::cli_abort("There was an issue with the downloaded file. I've deleted + withr::with_dir(download_dir, + utils::unzip(zipfile = download_file, exdir = download_dir)) + }, error = function(e) { + cli::cli_abort( + "There was an issue with the downloaded file. I've deleted this bad version of the downloaded file, please retry.", - call = rlang::caller_env()) - }, - finally = { - # clean up on success! - unlink(download_file) + call = rlang::caller_env() + ) }) + unlink(download_file) } - agfd_nc <- list.files(agfd_nc_dir, full.names = TRUE) class(agfd_nc) <- union("read.abares.agfd.nc.files", class(agfd_nc)) return(agfd_nc) From 8985f226887a596fe69cfc7e0437b07747375ed6 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 19:52:18 +0800 Subject: [PATCH 23/41] Add source and references to documentation and update link to file --- R/get_historical_state_estimates.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/get_historical_state_estimates.R b/R/get_historical_state_estimates.R index f807512..d42b484 100644 --- a/R/get_historical_state_estimates.R +++ b/R/get_historical_state_estimates.R @@ -9,7 +9,8 @@ #' `key`. #' @autoglobal #' @family Estimates -#' @source +#' @references +#' @source #' @export #' @examplesIf interactive() #' get_historical_state_estimates() @@ -21,7 +22,7 @@ get_historical_state_estimates <- get_hist_sta_est <- function() { f <- file.path(tempdir(), "fdp-beta-state-historical.csv") .retry_download( - "https://www.agriculture.gov.au/sites/default/files/documents/fdp-beta-state-historical.csv", + "https://www.agriculture.gov.au/sites/default/files/documents/fdp-state-historical.csv", .f = f) x <- data.table::fread(f) From c806249c89ac837f2b49aafaa5e8214eb9f0fe16 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 19:52:32 +0800 Subject: [PATCH 24/41] specify what files should be imported --- R/read_agfd_dt.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/read_agfd_dt.R b/R/read_agfd_dt.R index b930d1f..f0be7b2 100644 --- a/R/read_agfd_dt.R +++ b/R/read_agfd_dt.R @@ -5,7 +5,7 @@ #' #' @inherit get_agfd details #' -#' @param files A list of NetCDF files to import +#' @param files A list of \acronym{AGFD} NetCDF files to import #' #' @return a [data.table::data.table] object of the Australian Gridded Farm Data #' From 3d2d8a1ddc85ad3c87a8cd5ba6944c5e013ad7c8 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 19:52:45 +0800 Subject: [PATCH 25/41] redocument package --- man/get_estimates_by_size.Rd | 5 ++++- man/read_agfd_dt.Rd | 2 +- man/read_agfd_stars.Rd | 2 +- man/read_agfd_terra.Rd | 2 +- man/read_agfd_tidync.Rd | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/man/get_estimates_by_size.Rd b/man/get_estimates_by_size.Rd index 91f0da6..ee47eb1 100644 --- a/man/get_estimates_by_size.Rd +++ b/man/get_estimates_by_size.Rd @@ -5,7 +5,7 @@ \alias{get_est_by_size} \title{Get Estimates by Size From ABARES} \source{ -\url{https://www.agriculture.gov.au/abares/data/farm-data-portal#data-download} +\url{https://www.agriculture.gov.au/sites/default/files/documents/fdp-national-historical.csv} } \usage{ get_estimates_by_size() @@ -31,6 +31,9 @@ get_estimates_by_size() get_est_by_size() \dontshow{\}) # examplesIf} } +\references{ +\url{https://www.agriculture.gov.au/abares/data/farm-data-portal#data-download} +} \seealso{ Other Estimates: \code{\link{get_estimates_by_performance_category}()}, diff --git a/man/read_agfd_dt.Rd b/man/read_agfd_dt.Rd index b72efbd..a4e689f 100644 --- a/man/read_agfd_dt.Rd +++ b/man/read_agfd_dt.Rd @@ -7,7 +7,7 @@ read_agfd_dt(files) } \arguments{ -\item{files}{A list of NetCDF files to import} +\item{files}{A list of \acronym{AGFD} NetCDF files to import} } \value{ a \link[data.table:data.table]{data.table::data.table} object of the Australian Gridded Farm Data diff --git a/man/read_agfd_stars.Rd b/man/read_agfd_stars.Rd index 14f0ab5..04ab8d1 100644 --- a/man/read_agfd_stars.Rd +++ b/man/read_agfd_stars.Rd @@ -7,7 +7,7 @@ read_agfd_stars(files) } \arguments{ -\item{files}{A list of NetCDF files to import} +\item{files}{A list of \acronym{AGFD} NetCDF files to import} } \value{ a \code{list} object of \CRANpkg{stars} objects of the Australian Gridded diff --git a/man/read_agfd_terra.Rd b/man/read_agfd_terra.Rd index 4075bc5..5fc4f2d 100644 --- a/man/read_agfd_terra.Rd +++ b/man/read_agfd_terra.Rd @@ -7,7 +7,7 @@ read_agfd_terra(files) } \arguments{ -\item{files}{A list of NetCDF files to import} +\item{files}{A list of \acronym{AGFD} NetCDF files to import} } \value{ a \code{list} object of \link[terra:rast]{terra::rast} objects of the Australian Gridded diff --git a/man/read_agfd_tidync.Rd b/man/read_agfd_tidync.Rd index ae583ab..5f19630 100644 --- a/man/read_agfd_tidync.Rd +++ b/man/read_agfd_tidync.Rd @@ -7,7 +7,7 @@ read_agfd_tidync(files) } \arguments{ -\item{files}{A list of NetCDF files to import} +\item{files}{A list of \acronym{AGFD} NetCDF files to import} } \value{ a \code{list} object of \CRANpkg{tidync} \link[tidync:tidync]{tidync::tidync} objects of the From 0c4d6334b6f4e3277dfe8db7001c5b0989e8eb67 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 19:53:00 +0800 Subject: [PATCH 26/41] Update tests to align with new functionality --- tests/testthat/test-get_historical_national_estimates.R | 2 +- tests/testthat/test-get_historical_regional_estimates.R | 2 +- tests/testthat/test-retry_download.R | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-get_historical_national_estimates.R b/tests/testthat/test-get_historical_national_estimates.R index 605fc4b..2469784 100644 --- a/tests/testthat/test-get_historical_national_estimates.R +++ b/tests/testthat/test-get_historical_national_estimates.R @@ -12,7 +12,7 @@ test_that("get_historical_national_estimates works", { Year = "integer", Industry = "character", Value = "double", - RSE = "integer" + RSE = "double" ) ) }) diff --git a/tests/testthat/test-get_historical_regional_estimates.R b/tests/testthat/test-get_historical_regional_estimates.R index 15a903b..0871373 100644 --- a/tests/testthat/test-get_historical_regional_estimates.R +++ b/tests/testthat/test-get_historical_regional_estimates.R @@ -12,7 +12,7 @@ test_that("get_historical_regional_estimates works", { Year = "integer", ABARES_region = "character", Value = "double", - RSE = "integer" + RSE = "double" ) ) }) diff --git a/tests/testthat/test-retry_download.R b/tests/testthat/test-retry_download.R index 231f1a4..6ef82df 100644 --- a/tests/testthat/test-retry_download.R +++ b/tests/testthat/test-retry_download.R @@ -14,7 +14,7 @@ without_internet({ url = url, .f = f, .max_tries = 2L - ), regexp = "There was an error with this download, please retry.") + )) expect_no_condition(file.exists(f)) }) }) From a1827f06925a6b4ac31a553861fd62709976b800 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 19:53:24 +0800 Subject: [PATCH 27/41] Update codemeta.json --- codemeta.json | 62 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/codemeta.json b/codemeta.json index cd068e3..4302698 100644 --- a/codemeta.json +++ b/codemeta.json @@ -34,6 +34,18 @@ } ], "softwareSuggestions": [ + { + "@type": "SoftwareApplication", + "identifier": "httptest2", + "name": "httptest2", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=httptest2" + }, { "@type": "SoftwareApplication", "identifier": "knitr", @@ -116,6 +128,18 @@ "version": ">= 4.1.0" }, "2": { + "@type": "SoftwareApplication", + "identifier": "brio", + "name": "brio", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=brio" + }, + "3": { "@type": "SoftwareApplication", "identifier": "cli", "name": "cli", @@ -127,7 +151,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=cli" }, - "3": { + "4": { "@type": "SoftwareApplication", "identifier": "data.table", "name": "data.table", @@ -139,7 +163,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=data.table" }, - "4": { + "5": { "@type": "SoftwareApplication", "identifier": "httr2", "name": "httr2", @@ -151,7 +175,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=httr2" }, - "5": { + "6": { "@type": "SoftwareApplication", "identifier": "lubridate", "name": "lubridate", @@ -163,7 +187,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=lubridate" }, - "6": { + "7": { "@type": "SoftwareApplication", "identifier": "openxlsx2", "name": "openxlsx2", @@ -175,7 +199,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=openxlsx2" }, - "7": { + "8": { "@type": "SoftwareApplication", "identifier": "purrr", "name": "purrr", @@ -187,7 +211,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=purrr" }, - "8": { + "9": { "@type": "SoftwareApplication", "identifier": "readtext", "name": "readtext", @@ -199,7 +223,19 @@ }, "sameAs": "https://CRAN.R-project.org/package=readtext" }, - "9": { + "10": { + "@type": "SoftwareApplication", + "identifier": "rlang", + "name": "rlang", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=rlang" + }, + "11": { "@type": "SoftwareApplication", "identifier": "sf", "name": "sf", @@ -211,7 +247,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=sf" }, - "10": { + "12": { "@type": "SoftwareApplication", "identifier": "stars", "name": "stars", @@ -223,7 +259,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=stars" }, - "11": { + "13": { "@type": "SoftwareApplication", "identifier": "stringr", "name": "stringr", @@ -235,7 +271,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=stringr" }, - "12": { + "14": { "@type": "SoftwareApplication", "identifier": "terra", "name": "terra", @@ -247,7 +283,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=terra" }, - "13": { + "15": { "@type": "SoftwareApplication", "identifier": "tidync", "name": "tidync", @@ -259,7 +295,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=tidync" }, - "14": { + "16": { "@type": "SoftwareApplication", "identifier": "withr", "name": "withr", @@ -273,7 +309,7 @@ }, "SystemRequirements": null }, - "fileSize": "344.171KB", + "fileSize": "326.782KB", "citation": [ { "@type": "SoftwareSourceCode", From 4165502ef643999b333d14c8b221ebc4991e94a5 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:12:48 +0800 Subject: [PATCH 28/41] Lint test files --- tests/testthat/test-get_aagis_regions.R | 4 ++-- tests/testthat/test-get_abares_trade.R | 2 +- tests/testthat/test-get_abares_trade_regions.R | 2 +- tests/testthat/test-read_agfd_stars.R | 6 +++--- tests/testthat/test-read_agfd_terra.R | 8 ++++---- tests/testthat/test-read_agfd_tidync.R | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/testthat/test-get_aagis_regions.R b/tests/testthat/test-get_aagis_regions.R index 005edd8..87ad4fe 100644 --- a/tests/testthat/test-get_aagis_regions.R +++ b/tests/testthat/test-get_aagis_regions.R @@ -31,10 +31,10 @@ test_that("get_aagis_regions caches", { expect_true(file.exists( file.path(.find_user_cache(), "aagis_regions_dir/aagis.gpkg") )) - expect_true(!file.exists( + expect_false(file.exists( file.path(.find_user_cache(), "aagis_regions_dir/aagis_zip") )) - expect_true(!file.exists(file.path( + expect_false(file.exists(file.path( .find_user_cache(), "aagis_asgs16v1_g5a.*" ))) }) diff --git a/tests/testthat/test-get_abares_trade.R b/tests/testthat/test-get_abares_trade.R index 4f3387d..be205da 100644 --- a/tests/testthat/test-get_abares_trade.R +++ b/tests/testthat/test-get_abares_trade.R @@ -66,7 +66,7 @@ test_that("get_abares_trade caches", { expect_true(file.exists( file.path(.find_user_cache(), "abares_trade_dir/abares_trade.rds") )) - expect_true(!file.exists( + expect_false(file.exists( file.path(.find_user_cache(), "abares_trade_dir/abares_trade.zip") )) }) diff --git a/tests/testthat/test-get_abares_trade_regions.R b/tests/testthat/test-get_abares_trade_regions.R index 74091d8..edf407a 100644 --- a/tests/testthat/test-get_abares_trade_regions.R +++ b/tests/testthat/test-get_abares_trade_regions.R @@ -52,7 +52,7 @@ test_that("get_abares_trade_regions caches", { expect_true(file.exists( file.path(.find_user_cache(), "abares_trade_dir/abares_trade_regions.rds") )) - expect_true(!file.exists( + expect_false(file.exists( file.path(.find_user_cache(), "abares_trade_dir/abares_trade_regions.csv") )) }) diff --git a/tests/testthat/test-read_agfd_stars.R b/tests/testthat/test-read_agfd_stars.R index 1430a28..d2e468d 100644 --- a/tests/testthat/test-read_agfd_stars.R +++ b/tests/testthat/test-read_agfd_stars.R @@ -7,8 +7,8 @@ test_that("read_agfd_stars() returns a stars object", { expect_type(x, "list") expect_s3_class(x[[1]], "stars") - expect_identical( - names(x), + expect_named( + x, c( "f2022.c1991.p2022.t2022.nc", "f2022.c1992.p2022.t2022.nc", @@ -45,7 +45,7 @@ test_that("read_agfd_stars() returns a stars object", { "f2022.c2023.p2022.t2022.nc" ) ) - expect_identical( + expect_named( names(x[[1]]), c( "farmno", diff --git a/tests/testthat/test-read_agfd_terra.R b/tests/testthat/test-read_agfd_terra.R index 980f303..f7bd1f3 100644 --- a/tests/testthat/test-read_agfd_terra.R +++ b/tests/testthat/test-read_agfd_terra.R @@ -7,8 +7,8 @@ test_that("read_agfd_terra() returns a terra object", { expect_type(x, "list") expect_s4_class(x[[1]], "SpatRaster") - expect_identical( - names(x), + expect_named( + x, c( "f2022.c1991.p2022.t2022.nc", "f2022.c1992.p2022.t2022.nc", @@ -45,8 +45,8 @@ test_that("read_agfd_terra() returns a terra object", { "f2022.c2023.p2022.t2022.nc" ) ) - expect_identical( - names(x[[1]]), + expect_named( + x[[1]], c( "farmno", "R_total_hat_ha", diff --git a/tests/testthat/test-read_agfd_tidync.R b/tests/testthat/test-read_agfd_tidync.R index 5b0985c..8ec30f0 100644 --- a/tests/testthat/test-read_agfd_tidync.R +++ b/tests/testthat/test-read_agfd_tidync.R @@ -7,8 +7,8 @@ test_that("read_agfd_tidync() returns a tidync object", { expect_type(x, "list") expect_s3_class(x[[1]], "tidync") - expect_identical( - names(x), + expect_named( + x, c( "f2022.c1991.p2022.t2022.nc", "f2022.c1992.p2022.t2022.nc", From a611a228baf41e7fe838b0a0a73c0ddf470da45b Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:13:00 +0800 Subject: [PATCH 29/41] Update codemeta.json --- codemeta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemeta.json b/codemeta.json index 4302698..fd7515a 100644 --- a/codemeta.json +++ b/codemeta.json @@ -309,7 +309,7 @@ }, "SystemRequirements": null }, - "fileSize": "326.782KB", + "fileSize": "326.734KB", "citation": [ { "@type": "SoftwareSourceCode", From 3c2ad0ead24f6cc4a394c136450b5d0810983242 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:18:42 +0800 Subject: [PATCH 30/41] Correct test --- tests/testthat/test-read_agfd_stars.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-read_agfd_stars.R b/tests/testthat/test-read_agfd_stars.R index d2e468d..882fd9e 100644 --- a/tests/testthat/test-read_agfd_stars.R +++ b/tests/testthat/test-read_agfd_stars.R @@ -1,4 +1,5 @@ + test_that("read_agfd_stars() returns a stars object", { skip_if_offline() skip_on_ci() @@ -46,7 +47,7 @@ test_that("read_agfd_stars() returns a stars object", { ) ) expect_named( - names(x[[1]]), + x[[1]], c( "farmno", "R_total_hat_ha", From f5d796e5266c80a664090fd5cf4e9f35b68d646c Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:18:53 +0800 Subject: [PATCH 31/41] Update codemeta.json --- codemeta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemeta.json b/codemeta.json index fd7515a..cdc6652 100644 --- a/codemeta.json +++ b/codemeta.json @@ -309,7 +309,7 @@ }, "SystemRequirements": null }, - "fileSize": "326.734KB", + "fileSize": "326.728KB", "citation": [ { "@type": "SoftwareSourceCode", From 6d4afc481a4fe947db0eccdbd55f9c3f05ab53ee Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:46:12 +0800 Subject: [PATCH 32/41] use cli::cat_line() and don't force newlines, let {cli} do that --- R/get_agfd.R | 2 +- R/get_soil_thickness.R | 2 +- R/inspect_cache.R | 2 +- codemeta.json | 2 +- tests/testthat/test-get_agfd.R | 12 ++++++------ tests/testthat/test-get_soil_thickness.R | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/R/get_agfd.R b/R/get_agfd.R index a55fcfc..1ce2f5c 100644 --- a/R/get_agfd.R +++ b/R/get_agfd.R @@ -127,7 +127,7 @@ get_agfd <- function(fixed_prices = TRUE, #' @autoglobal #' @noRd print.read.abares.agfd.nc.files <- function(x, ...) { - cli::cli_h1("\nLocally Available ABARES AGFD NetCDF Files\n") + cli::cli_h1("Locally Available ABARES AGFD NetCDF Files") cli::cli_ul(basename(x)) cat("\n") invisible(x) diff --git a/R/get_soil_thickness.R b/R/get_soil_thickness.R index 17474d4..9c7bd81 100644 --- a/R/get_soil_thickness.R +++ b/R/get_soil_thickness.R @@ -184,6 +184,6 @@ print_soil_thickness_metadata <- function(x) { cli::cli_h1("Soil Thickness for Australian areas of intensive agriculture of Layer 1 (A Horizon - top-soil)\n") cli::cli_h2("Dataset ANZLIC ID ANZCW1202000149") cli::cli_text(x$metadata) - cat("\n") + cli::cat_line() invisible(x) } diff --git a/R/inspect_cache.R b/R/inspect_cache.R index dae98b0..6c60b80 100644 --- a/R/inspect_cache.R +++ b/R/inspect_cache.R @@ -45,7 +45,7 @@ inspect_cache <- function(recursive = FALSE) { ) )) } else { - cli::cli_h1("\nLocally Available {{read.abares}} Cached Files\n") + cli::cli_h1("Locally Available {{read.abares}} Cached Files") cli::cli_ul(basename(f)) } } diff --git a/codemeta.json b/codemeta.json index cdc6652..b169ee3 100644 --- a/codemeta.json +++ b/codemeta.json @@ -309,7 +309,7 @@ }, "SystemRequirements": null }, - "fileSize": "326.728KB", + "fileSize": "326.744KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/tests/testthat/test-get_agfd.R b/tests/testthat/test-get_agfd.R index c74e75a..69bd414 100644 --- a/tests/testthat/test-get_agfd.R +++ b/tests/testthat/test-get_agfd.R @@ -7,9 +7,9 @@ test_that("get_agfd, fixed = TRUE works", { agfd_nc <- list.files(agfd_nc_dir, full.names = TRUE) nc_files <- function(agfd_nc_dir) { - cli::cli_h1("\nLocally Available ABARES AGFD NetCDF Files\n") + cli::cli_h1("Locally Available ABARES AGFD NetCDF Files") cli::cli_ul(basename(list.files(agfd_nc_dir))) - cat("\n") + cli::cat_line() } print_out <- capture.output(nc_files) @@ -32,9 +32,9 @@ test_that("get_agfd, fixed = FALSE works", { agfd_nc <- list.files(agfd_nc_dir, full.names = TRUE) nc_files <- function(agfd_nc_dir) { - cli::cli_h1("\nLocally Available ABARES AGFD NetCDF Files\n") + cli::cli_h1("Locally Available ABARES AGFD NetCDF Files") cli::cli_ul(basename(list.files(agfd_nc_dir))) - cat("\n") + cli::cat_line() } print_out <- capture.output(nc_files) @@ -88,9 +88,9 @@ test_that("print.read.abares.agfd.nc.files returns a properly formatted list", skip_if_offline() skip_on_ci() print_out <- function(x) { - cli::cli_h1("\nLocally Available ABARES AGFD NetCDF Files\n") + cli::cli_h1("Locally Available ABARES AGFD NetCDF Files") cli::cli_ul(basename(x)) - cat("\n") + cli::cat_line() } x <- get_agfd(cache = TRUE) diff --git a/tests/testthat/test-get_soil_thickness.R b/tests/testthat/test-get_soil_thickness.R index f5e489a..b513ac5 100644 --- a/tests/testthat/test-get_soil_thickness.R +++ b/tests/testthat/test-get_soil_thickness.R @@ -82,7 +82,7 @@ test_that("print.read.abares.thickness.files prints metadata", { cli::cli_text("To see the full metadata, call {.fn print_soil_thickness_metadata} on a soil thickness object in your R session.") - cat("\n") + cli::cat_line() } print_out <- capture.output(out_text()) @@ -101,7 +101,7 @@ test_that("print_soil_thickness_metadata prints full metadata", { ) cli::cli_h2("Dataset ANZLIC ID ANZCW1202000149") cli::cli_text(x$metadata) - cat("\n") + cli::cat_line() } x <- get_soil_thickness(cache = TRUE) From b3ccc66381ac1806545baa00c09635c535d15f8a Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:46:59 +0800 Subject: [PATCH 33/41] missed a `cat("\n")` --- R/get_soil_thickness.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/get_soil_thickness.R b/R/get_soil_thickness.R index 9c7bd81..9ce621e 100644 --- a/R/get_soil_thickness.R +++ b/R/get_soil_thickness.R @@ -152,7 +152,7 @@ print.read.abares.soil.thickness.files <- function(x, ...) { cli::cli_text("To see the full metadata, call {.fn print_soil_thickness_metadata} on a soil thickness object in your R session.") - cat("\n") + cli::cat_line() invisible(x) } From c0a16d766bb8d0bb97e2bfe002d5987466a3ad82 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:54:34 +0800 Subject: [PATCH 34/41] Fix source and references for estimates by size/performance --- R/get_estimates_by_performance_category.R | 3 ++- codemeta.json | 2 +- man/get_estimates_by_performance_category.Rd | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/R/get_estimates_by_performance_category.R b/R/get_estimates_by_performance_category.R index de91cba..362a7f8 100644 --- a/R/get_estimates_by_performance_category.R +++ b/R/get_estimates_by_performance_category.R @@ -3,7 +3,8 @@ #' #' @return A [data.table::data.table] object #' @export -#' @source +#' @references +#' @source #' @family Estimates #' @autoglobal #' @examplesIf interactive() diff --git a/codemeta.json b/codemeta.json index b169ee3..914e291 100644 --- a/codemeta.json +++ b/codemeta.json @@ -309,7 +309,7 @@ }, "SystemRequirements": null }, - "fileSize": "326.744KB", + "fileSize": "326.968KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/man/get_estimates_by_performance_category.Rd b/man/get_estimates_by_performance_category.Rd index 208da48..27d1104 100644 --- a/man/get_estimates_by_performance_category.Rd +++ b/man/get_estimates_by_performance_category.Rd @@ -5,7 +5,7 @@ \alias{get_est_by_perf_cat} \title{Get Estimates by Size From ABARES} \source{ -\url{https://www.agriculture.gov.au/abares/data/farm-data-portal#data-download} +\url{https://www.agriculture.gov.au/sites/default/files/documents/fdp-BySize-ByPerformance.csv} } \usage{ get_estimates_by_performance_category() @@ -27,6 +27,9 @@ Get Estimates by Size From ABARES get_est_by_perf_cat() \dontshow{\}) # examplesIf} } +\references{ +\url{https://www.agriculture.gov.au/abares/data/farm-data-portal#data-download} +} \seealso{ Other Estimates: \code{\link{get_estimates_by_size}()}, From 121f11cf0317286193389e51326b0b232b2dba90 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 21:14:42 +0800 Subject: [PATCH 35/41] Add source/rerferences to forecast database --- R/get_historical_forecast_database.R | 3 ++- man/get_historical_forecast_database.Rd | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/R/get_historical_forecast_database.R b/R/get_historical_forecast_database.R index 181a792..67a37e9 100644 --- a/R/get_historical_forecast_database.R +++ b/R/get_historical_forecast_database.R @@ -26,7 +26,8 @@ #' The "Month_issued" column is converted from a character string to a numeric #' value representing the month of year, _e.g._, "March" is converted to `3`. #' -#' @source +#' @source +#' @references #' #' @return A [data.table::data.table] object. #' diff --git a/man/get_historical_forecast_database.Rd b/man/get_historical_forecast_database.Rd index 7f72550..221f5fb 100644 --- a/man/get_historical_forecast_database.Rd +++ b/man/get_historical_forecast_database.Rd @@ -5,7 +5,7 @@ \alias{get_historical_forecast} \title{Get Historical Forecast Database From ABARES} \source{ -\url{https://www.agriculture.gov.au/abares/research-topics/agricultural-outlook/historical-forecasts#:~:text=About\%20the\%20historical\%20agricultural\%20forecast,relevant\%20to\%20Australian\%20agricultural\%20markets} +\url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1031941/0} } \usage{ get_historical_forecast_database() @@ -54,3 +54,6 @@ get_historical_forecast_database() get_historical_forecast() \dontshow{\}) # examplesIf} } +\references{ +\url{https://www.agriculture.gov.au/abares/research-topics/agricultural-outlook/historical-forecasts#:~:text=About\%20the\%20historical\%20agricultural\%20forecast,relevant\%20to\%20Australian\%20agricultural\%20markets} +} From 37f16a24d9a4ebb6f6d281fc6127364345ff86a0 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 21:16:31 +0800 Subject: [PATCH 36/41] formatting in documentation --- R/get_historical_forecast_database.R | 6 +++--- man/get_historical_forecast_database.Rd | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/get_historical_forecast_database.R b/R/get_historical_forecast_database.R index 67a37e9..81da925 100644 --- a/R/get_historical_forecast_database.R +++ b/R/get_historical_forecast_database.R @@ -7,10 +7,10 @@ #' | Field | Description | #' |-------|-------------| #' | Commodity | Broad description of commodity (includes the Australian dollar) | -#' | Estimate_type | Broad grouping of estimate by theme e.g. animal numbers, area, production, price, export and volume measures. | +#' | Estimate_type | Broad grouping of estimate by theme *e.g.*, animal numbers, area, production, price, export and volume measures. | #' | Estimate_description | Detailed description of each series. | -#' | Unit | Measurement unit of series. e.g. kt, $m, $/t. | -#' | Region | Relevant region for each series. "World" denotes relevant international market. | +#' | Unit | Measurement unit of series. *e.g.*, kt, $m, $/t. | +#' | Region | Relevant region for each series. \dQuote{World} denotes relevant international market. | #' | Year_Issued | Year that forecast was originally issued. | #' | Month_issued | Month that forecast was originally issued. | #' | Year_Issued_FY | Australian financial year (July-June) that forecast was originally issued. | diff --git a/man/get_historical_forecast_database.Rd b/man/get_historical_forecast_database.Rd index 221f5fb..c8df1e7 100644 --- a/man/get_historical_forecast_database.Rd +++ b/man/get_historical_forecast_database.Rd @@ -22,10 +22,10 @@ Get Historical Forecast Database From ABARES \tabular{ll}{ Field \tab Description \cr Commodity \tab Broad description of commodity (includes the Australian dollar) \cr - Estimate_type \tab Broad grouping of estimate by theme e.g. animal numbers, area, production, price, export and volume measures. \cr + Estimate_type \tab Broad grouping of estimate by theme \emph{e.g.}, animal numbers, area, production, price, export and volume measures. \cr Estimate_description \tab Detailed description of each series. \cr - Unit \tab Measurement unit of series. e.g. kt, $m, $/t. \cr - Region \tab Relevant region for each series. "World" denotes relevant international market. \cr + Unit \tab Measurement unit of series. \emph{e.g.}, kt, $m, $/t. \cr + Region \tab Relevant region for each series. \dQuote{World} denotes relevant international market. \cr Year_Issued \tab Year that forecast was originally issued. \cr Month_issued \tab Month that forecast was originally issued. \cr Year_Issued_FY \tab Australian financial year (July-June) that forecast was originally issued. \cr From 39b6a7198b5040d1d25397a724d7c23eb9a410fa Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:54:58 +0800 Subject: [PATCH 37/41] add sources for AGFD documentation --- R/get_agfd.R | 4 ++++ codemeta.json | 2 +- man/get_agfd.Rd | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/R/get_agfd.R b/R/get_agfd.R index 1ce2f5c..efded0b 100644 --- a/R/get_agfd.R +++ b/R/get_agfd.R @@ -60,6 +60,10 @@ #' 2022, 100420, ISSN 2212-0963, DOI: #' [10.1016/j.crm.2022.100420](https://doi.org/10.1016/j.crm.2022.100420). #' +#' @source +#' * Historical climate prices fixed -- , +#' * Historical climate and prices -- +#' #' @examplesIf interactive() #' get_agfd() #' diff --git a/codemeta.json b/codemeta.json index 914e291..95582a5 100644 --- a/codemeta.json +++ b/codemeta.json @@ -309,7 +309,7 @@ }, "SystemRequirements": null }, - "fileSize": "326.968KB", + "fileSize": "327.684KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/man/get_agfd.Rd b/man/get_agfd.Rd index fa8c7c3..f7c6772 100644 --- a/man/get_agfd.Rd +++ b/man/get_agfd.Rd @@ -74,6 +74,12 @@ N. Hughes, W.Y. Soh, C. Boult, K. Lawson, \emph{Defining drought from the perspective of Australian farmers}, Climate Risk Management, Volume 35, 2022, 100420, ISSN 2212-0963, DOI: \href{https://doi.org/10.1016/j.crm.2022.100420}{10.1016/j.crm.2022.100420}. + +@source +\itemize{ +\item Historical climate prices fixed -- \url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1036161/3}, +\item Historical climate and prices -- \url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1036161/2} +} } \seealso{ Other AGFD: From fb783a8778ddcbe121199191a5d98ddb1a2a3f80 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 3 Dec 2024 22:37:34 +0800 Subject: [PATCH 38/41] fix source in agfd --- R/get_agfd.R | 2 +- man/get_agfd.Rd | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/get_agfd.R b/R/get_agfd.R index efded0b..864559c 100644 --- a/R/get_agfd.R +++ b/R/get_agfd.R @@ -60,7 +60,7 @@ #' 2022, 100420, ISSN 2212-0963, DOI: #' [10.1016/j.crm.2022.100420](https://doi.org/10.1016/j.crm.2022.100420). #' -#' @source +#' @source #' * Historical climate prices fixed -- , #' * Historical climate and prices -- #' diff --git a/man/get_agfd.Rd b/man/get_agfd.Rd index f7c6772..b6f75db 100644 --- a/man/get_agfd.Rd +++ b/man/get_agfd.Rd @@ -3,6 +3,12 @@ \name{get_agfd} \alias{get_agfd} \title{Fetch Australian Gridded Farm Data} +\source{ +\itemize{ +\item Historical climate prices fixed -- \url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1036161/3}, +\item Historical climate and prices -- \url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1036161/2} +} +} \usage{ get_agfd(fixed_prices = TRUE, cache = TRUE) } @@ -74,12 +80,6 @@ N. Hughes, W.Y. Soh, C. Boult, K. Lawson, \emph{Defining drought from the perspective of Australian farmers}, Climate Risk Management, Volume 35, 2022, 100420, ISSN 2212-0963, DOI: \href{https://doi.org/10.1016/j.crm.2022.100420}{10.1016/j.crm.2022.100420}. - -@source -\itemize{ -\item Historical climate prices fixed -- \url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1036161/3}, -\item Historical climate and prices -- \url{https://daff.ent.sirsidynix.net.au/client/en_AU/search/asset/1036161/2} -} } \seealso{ Other AGFD: From 0fe8cf0f62af37e5b7d4f6a6ed254c4d728ba744 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:55:09 +0800 Subject: [PATCH 39/41] update codemeta.json --- codemeta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemeta.json b/codemeta.json index 95582a5..4a74df0 100644 --- a/codemeta.json +++ b/codemeta.json @@ -309,7 +309,7 @@ }, "SystemRequirements": null }, - "fileSize": "327.684KB", + "fileSize": "327.685KB", "citation": [ { "@type": "SoftwareSourceCode", From 891a313ab50a5bfd1d449f75806425c7979b3bd2 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:53:40 +0800 Subject: [PATCH 40/41] use cli::cat_line() and don't force newlines, let {cli} do that --- codemeta.json | 333 -------------------------------------------------- 1 file changed, 333 deletions(-) delete mode 100644 codemeta.json diff --git a/codemeta.json b/codemeta.json deleted file mode 100644 index 4a74df0..0000000 --- a/codemeta.json +++ /dev/null @@ -1,333 +0,0 @@ -{ - "@context": "https://doi.org/10.5063/schema/codemeta-2.0", - "@type": "SoftwareSourceCode", - "identifier": "read.abares", - "description": "Download and import data from the Australian Bureau of Agricultural and Resource Economics and Sciences (ABARES) .", - "name": "read.abares: Provides simple downloading, parsing and importing of Australian\n Bureau of Agricultural and Resource Economics and Sciences (ABARES)\n data sources", - "relatedLink": "https://adamhsparks.github.io/read.abares/", - "codeRepository": "https://github.com/adamhsparks/read.abares", - "issueTracker": "https://github.com/adamhsparks/read.abares/issues", - "license": "https://spdx.org/licenses/MIT", - "version": "0.1.0", - "programmingLanguage": { - "@type": "ComputerLanguage", - "name": "R", - "url": "https://r-project.org" - }, - "runtimePlatform": "R version 4.4.2 (2024-10-31)", - "author": [ - { - "@type": "Person", - "givenName": "Adam H.", - "familyName": "Sparks", - "email": "adamhsparks@gmail.com", - "@id": "https://orcid.org/0000-0002-0061-8359" - } - ], - "maintainer": [ - { - "@type": "Person", - "givenName": "Adam H.", - "familyName": "Sparks", - "email": "adamhsparks@gmail.com", - "@id": "https://orcid.org/0000-0002-0061-8359" - } - ], - "softwareSuggestions": [ - { - "@type": "SoftwareApplication", - "identifier": "httptest2", - "name": "httptest2", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=httptest2" - }, - { - "@type": "SoftwareApplication", - "identifier": "knitr", - "name": "knitr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=knitr" - }, - { - "@type": "SoftwareApplication", - "identifier": "pander", - "name": "pander", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=pander" - }, - { - "@type": "SoftwareApplication", - "identifier": "rmarkdown", - "name": "rmarkdown", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=rmarkdown" - }, - { - "@type": "SoftwareApplication", - "identifier": "roxyglobals", - "name": "roxyglobals", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=roxyglobals" - }, - { - "@type": "SoftwareApplication", - "identifier": "spelling", - "name": "spelling", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=spelling" - }, - { - "@type": "SoftwareApplication", - "identifier": "testthat", - "name": "testthat", - "version": ">= 3.0.0", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=testthat" - } - ], - "softwareRequirements": { - "1": { - "@type": "SoftwareApplication", - "identifier": "R", - "name": "R", - "version": ">= 4.1.0" - }, - "2": { - "@type": "SoftwareApplication", - "identifier": "brio", - "name": "brio", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=brio" - }, - "3": { - "@type": "SoftwareApplication", - "identifier": "cli", - "name": "cli", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=cli" - }, - "4": { - "@type": "SoftwareApplication", - "identifier": "data.table", - "name": "data.table", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=data.table" - }, - "5": { - "@type": "SoftwareApplication", - "identifier": "httr2", - "name": "httr2", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=httr2" - }, - "6": { - "@type": "SoftwareApplication", - "identifier": "lubridate", - "name": "lubridate", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=lubridate" - }, - "7": { - "@type": "SoftwareApplication", - "identifier": "openxlsx2", - "name": "openxlsx2", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=openxlsx2" - }, - "8": { - "@type": "SoftwareApplication", - "identifier": "purrr", - "name": "purrr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=purrr" - }, - "9": { - "@type": "SoftwareApplication", - "identifier": "readtext", - "name": "readtext", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=readtext" - }, - "10": { - "@type": "SoftwareApplication", - "identifier": "rlang", - "name": "rlang", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=rlang" - }, - "11": { - "@type": "SoftwareApplication", - "identifier": "sf", - "name": "sf", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=sf" - }, - "12": { - "@type": "SoftwareApplication", - "identifier": "stars", - "name": "stars", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=stars" - }, - "13": { - "@type": "SoftwareApplication", - "identifier": "stringr", - "name": "stringr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=stringr" - }, - "14": { - "@type": "SoftwareApplication", - "identifier": "terra", - "name": "terra", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=terra" - }, - "15": { - "@type": "SoftwareApplication", - "identifier": "tidync", - "name": "tidync", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=tidync" - }, - "16": { - "@type": "SoftwareApplication", - "identifier": "withr", - "name": "withr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=withr" - }, - "SystemRequirements": null - }, - "fileSize": "327.685KB", - "citation": [ - { - "@type": "SoftwareSourceCode", - "author": [ - { - "@type": "Person", - "givenName": "Adam H.", - "familyName": "Sparks" - } - ], - "name": "{read.abares}: Simple downloading and importing of ABARES Data", - "url": "https://adamhsparks.codeberg.page/read.abares/", - "description": "R package version 0.1.0" - } - ], - "releaseNotes": "https://github.com/adamhsparks/read.abares/blob/master/NEWS.md", - "readme": "https://github.com/adamhsparks/read.abares/blob/main/README.md", - "contIntegration": ["https://github.com/adamhsparks/read.abares/actions/workflows/R-CMD-check.yaml", "https://app.codecov.io/gh/adamhsparks/read.abares"], - "developmentStatus": ["https://lifecycle.r-lib.org/articles/stages.html#stable", "https://www.repostatus.org/#active"], - "keywords": ["agriculture", "australia", "data-retrieval", "open-data", "open-datasets", "r"] -} From 9f30f013d83038162bcef3e1cd1e6045e57c77e7 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Wed, 4 Dec 2024 12:56:57 +0800 Subject: [PATCH 41/41] re-add codemeta.json --- codemeta.json | 333 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 333 insertions(+) create mode 100644 codemeta.json diff --git a/codemeta.json b/codemeta.json new file mode 100644 index 0000000..4a74df0 --- /dev/null +++ b/codemeta.json @@ -0,0 +1,333 @@ +{ + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", + "@type": "SoftwareSourceCode", + "identifier": "read.abares", + "description": "Download and import data from the Australian Bureau of Agricultural and Resource Economics and Sciences (ABARES) .", + "name": "read.abares: Provides simple downloading, parsing and importing of Australian\n Bureau of Agricultural and Resource Economics and Sciences (ABARES)\n data sources", + "relatedLink": "https://adamhsparks.github.io/read.abares/", + "codeRepository": "https://github.com/adamhsparks/read.abares", + "issueTracker": "https://github.com/adamhsparks/read.abares/issues", + "license": "https://spdx.org/licenses/MIT", + "version": "0.1.0", + "programmingLanguage": { + "@type": "ComputerLanguage", + "name": "R", + "url": "https://r-project.org" + }, + "runtimePlatform": "R version 4.4.2 (2024-10-31)", + "author": [ + { + "@type": "Person", + "givenName": "Adam H.", + "familyName": "Sparks", + "email": "adamhsparks@gmail.com", + "@id": "https://orcid.org/0000-0002-0061-8359" + } + ], + "maintainer": [ + { + "@type": "Person", + "givenName": "Adam H.", + "familyName": "Sparks", + "email": "adamhsparks@gmail.com", + "@id": "https://orcid.org/0000-0002-0061-8359" + } + ], + "softwareSuggestions": [ + { + "@type": "SoftwareApplication", + "identifier": "httptest2", + "name": "httptest2", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=httptest2" + }, + { + "@type": "SoftwareApplication", + "identifier": "knitr", + "name": "knitr", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=knitr" + }, + { + "@type": "SoftwareApplication", + "identifier": "pander", + "name": "pander", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=pander" + }, + { + "@type": "SoftwareApplication", + "identifier": "rmarkdown", + "name": "rmarkdown", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=rmarkdown" + }, + { + "@type": "SoftwareApplication", + "identifier": "roxyglobals", + "name": "roxyglobals", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=roxyglobals" + }, + { + "@type": "SoftwareApplication", + "identifier": "spelling", + "name": "spelling", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=spelling" + }, + { + "@type": "SoftwareApplication", + "identifier": "testthat", + "name": "testthat", + "version": ">= 3.0.0", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=testthat" + } + ], + "softwareRequirements": { + "1": { + "@type": "SoftwareApplication", + "identifier": "R", + "name": "R", + "version": ">= 4.1.0" + }, + "2": { + "@type": "SoftwareApplication", + "identifier": "brio", + "name": "brio", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=brio" + }, + "3": { + "@type": "SoftwareApplication", + "identifier": "cli", + "name": "cli", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=cli" + }, + "4": { + "@type": "SoftwareApplication", + "identifier": "data.table", + "name": "data.table", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=data.table" + }, + "5": { + "@type": "SoftwareApplication", + "identifier": "httr2", + "name": "httr2", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=httr2" + }, + "6": { + "@type": "SoftwareApplication", + "identifier": "lubridate", + "name": "lubridate", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=lubridate" + }, + "7": { + "@type": "SoftwareApplication", + "identifier": "openxlsx2", + "name": "openxlsx2", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=openxlsx2" + }, + "8": { + "@type": "SoftwareApplication", + "identifier": "purrr", + "name": "purrr", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=purrr" + }, + "9": { + "@type": "SoftwareApplication", + "identifier": "readtext", + "name": "readtext", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=readtext" + }, + "10": { + "@type": "SoftwareApplication", + "identifier": "rlang", + "name": "rlang", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=rlang" + }, + "11": { + "@type": "SoftwareApplication", + "identifier": "sf", + "name": "sf", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=sf" + }, + "12": { + "@type": "SoftwareApplication", + "identifier": "stars", + "name": "stars", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=stars" + }, + "13": { + "@type": "SoftwareApplication", + "identifier": "stringr", + "name": "stringr", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=stringr" + }, + "14": { + "@type": "SoftwareApplication", + "identifier": "terra", + "name": "terra", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=terra" + }, + "15": { + "@type": "SoftwareApplication", + "identifier": "tidync", + "name": "tidync", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=tidync" + }, + "16": { + "@type": "SoftwareApplication", + "identifier": "withr", + "name": "withr", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=withr" + }, + "SystemRequirements": null + }, + "fileSize": "327.685KB", + "citation": [ + { + "@type": "SoftwareSourceCode", + "author": [ + { + "@type": "Person", + "givenName": "Adam H.", + "familyName": "Sparks" + } + ], + "name": "{read.abares}: Simple downloading and importing of ABARES Data", + "url": "https://adamhsparks.codeberg.page/read.abares/", + "description": "R package version 0.1.0" + } + ], + "releaseNotes": "https://github.com/adamhsparks/read.abares/blob/master/NEWS.md", + "readme": "https://github.com/adamhsparks/read.abares/blob/main/README.md", + "contIntegration": ["https://github.com/adamhsparks/read.abares/actions/workflows/R-CMD-check.yaml", "https://app.codecov.io/gh/adamhsparks/read.abares"], + "developmentStatus": ["https://lifecycle.r-lib.org/articles/stages.html#stable", "https://www.repostatus.org/#active"], + "keywords": ["agriculture", "australia", "data-retrieval", "open-data", "open-datasets", "r"] +}