diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 449fcdd9..eabf2e45 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -96,7 +96,7 @@ jobs: - name: Install Linux dependencies if: runner.os == 'Linux' # update the below with sysreqs::sysreqs("DESCRIPTION") and check the "DEB" entries (for Ubuntu). - # we don't want to depend on the sysreqs pkg here, as it requires a quite new R version + # we don't want to depend on the sysreqs pkg here, as it requires quite a recent R version # as of May 2021: https://sysreqs.r-hub.io/pkg/AMR,R,cleaner,curl,dplyr,ggplot2,ggtext,knitr,microbenchmark,pillar,readxl,rmarkdown,rstudioapi,rvest,skimr,tidyr,tinytest,xml2,backports,crayon,rlang,vctrs,evaluate,highr,markdown,stringr,yaml,xfun,cli,ellipsis,fansi,lifecycle,utf8,glue,mime,magrittr,stringi,generics,R6,tibble,tidyselect,pkgconfig,purrr,digest,gtable,isoband,MASS,mgcv,scales,withr,nlme,Matrix,farver,labeling,munsell,RColorBrewer,viridisLite,lattice,colorspace,gridtext,Rcpp,RCurl,png,jpeg,bitops,cellranger,progress,rematch,hms,prettyunits,htmltools,jsonlite,tinytex,base64enc,httr,selectr,openssl,askpass,sys,repr,cpp11 run: | sudo apt install -y libssl-dev pandoc pandoc-citeproc libxml2-dev libicu-dev libcurl4-openssl-dev libpng-dev @@ -109,29 +109,33 @@ jobs: path: ${{ env.R_LIBS_USER }} key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-v4 - - name: Install AMR and tinytest and update dependencies + - name: Unpack AMR and install R dependencies + if: always() run: | + tar -xf data-raw/AMR_latest.tar.gz source("data-raw/_install_deps.R") shell: Rscript {0} - name: Show session info + if: always() run: | options(width = 100) utils::sessionInfo() as.data.frame(utils::installed.packages())[, "Version", drop = FALSE] shell: Rscript {0} - - name: Unpack shipped version and remove vignettes - if: always() + - name: Only keep vignettes on release version + if: matrix.config.r != 'release' + # writing to DESCRIPTION2 and then moving to DESCRIPTION is required for R < 3.3 as writeLines() cannot overwrite run: | - tar -xf data-raw/AMR_latest.tar.gz rm -rf AMR/vignettes - Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[!grepl('VignetteBuilder', readLines('AMR/DESCRIPTION'))], 'AMR/DESCRIPTION')" - Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[gsub(' +', '', readLines('AMR/DESCRIPTION')) != ''], 'AMR/DESCRIPTION')" - find AMR -name 'DESCRIPTION' -exec cat '{}' \; || true + Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[!grepl('VignetteBuilder', readLines('AMR/DESCRIPTION'))], 'AMR/DESCRIPTION2')" + rm AMR/DESCRIPTION + mv AMR/DESCRIPTION2 AMR/DESCRIPTION shell: bash - name: Run R CMD check + if: always() env: _R_CHECK_CRAN_INCOMING_: false _R_CHECK_FORCE_SUGGESTS_: false @@ -142,7 +146,7 @@ jobs: R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }} R_RUN_TINYTEST: true run: | - R CMD check --no-manual --no-vignettes --no-build-vignettes --ignore-vignettes AMR + R CMD check --no-manual AMR shell: bash - name: Show unit tests output diff --git a/DESCRIPTION b/DESCRIPTION index 257c9916..e456921d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.6.0.9049 -Date: 2021-05-19 +Version: 1.6.0.9050 +Date: 2021-05-20 Title: Antimicrobial Resistance Data Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 709c4861..b2f40e96 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# `AMR` 1.6.0.9049 -## Last updated: 19 May 2021 +# `AMR` 1.6.0.9050 +## Last updated: 20 May 2021 ### Breaking change * All antibiotic class selectors (such as `carbapenems()`, `aminoglycosides()`) can now be used for filtering as well, making all their accompanying `filter_*()` functions redundant (such as `filter_carbapenems()`, `filter_aminoglycosides()`). These functions are now deprecated and will be removed in a next release. diff --git a/R/atc_online.R b/R/atc_online.R index b9a8df52..bf72e9e1 100644 --- a/R/atc_online.R +++ b/R/atc_online.R @@ -56,7 +56,7 @@ #' - `"TU"` = thousand units #' - `"MU"` = million units #' - `"mmol"` = millimole -#' - `"ml"` = milliliter (e.g. eyedrops) +#' - `"ml"` = millilitre (e.g. eyedrops) #' #' **N.B. This function requires an internet connection and only works if the following packages are installed: `curl`, `rvest`, `xml2`.** #' @export diff --git a/R/custom_eucast_rules.R b/R/custom_eucast_rules.R index ad5915cd..b1ae92fb 100644 --- a/R/custom_eucast_rules.R +++ b/R/custom_eucast_rules.R @@ -108,7 +108,7 @@ #' custom_eucast_rules(TZP == "R" ~ carbapenems == "R")) #' x2 custom_eucast_rules <- function(...) { - + dots <- tryCatch(list(...), error = function(e) "error") stop_if(identical(dots, "error"), @@ -150,7 +150,6 @@ custom_eucast_rules <- function(...) { result_group <- tryCatch( suppressWarnings(as.ab(result_group, fast_mode = TRUE, - info = FALSE, flag_multiple_results = FALSE)), error = function(e) NA_character_) } @@ -203,7 +202,9 @@ print.custom_eucast_rules <- function(x, ...) { for (i in seq_len(length(x))) { rule <- x[[i]] rule$query <- format_custom_query_rule(rule$query) - if (rule$result_value == "R") { + if (is.na(rule$result_value)) { + val <- font_red("") + } else if (rule$result_value == "R") { val <- font_rsi_R_bg(font_black(" R ")) } else if (rule$result_value == "S") { val <- font_rsi_S_bg(font_black(" S ")) diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index ae4a6546..a31dcbcc 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/data-raw/_install_deps.R b/data-raw/_install_deps.R index edb870df..846fd5e3 100644 --- a/data-raw/_install_deps.R +++ b/data-raw/_install_deps.R @@ -23,32 +23,31 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -install.packages("data-raw/AMR_latest.tar.gz", dependencies = FALSE) - # some old R instances have trouble installing tinytest, so we ship it too install.packages("data-raw/tinytest_1.2.4.patched.tar.gz") -pkg_suggests <- AMR:::trimws(unlist(strsplit(packageDescription("AMR")$Suggests, ",(\n)?"))) +descr <- readLines("AMR/DESCRIPTION") +pkg_suggests <- gsub(".*Suggests: (.*)*?[A-Z].*", "\\1", paste0(descr, "*", collapse = ""), perl = FALSE) +pkg_suggests <- unlist(strsplit(pkg_suggests, "[,* ]")) +pkg_suggests <- pkg_suggests[pkg_suggests != ""] +cat("Packages listed in Suggests:", paste(pkg_suggests, collapse = ", "), "\n") to_install <- pkg_suggests[!pkg_suggests %in% rownames(utils::installed.packages())] to_update <- as.data.frame(utils::old.packages(repos = "https://cran.rstudio.com/"), stringsAsFactors = FALSE) +to_update <- to_update[which(to_update$Package %in% pkg_suggests), "Package", drop = TRUE] for (i in seq_len(length(to_install))) { - if (isTRUE(is.character(to_install[i]))) { - cat("Installing package", to_install[i], "\n") - tryCatch(install.packages(to_install[i], repos = "https://cran.rstudio.com/", dependencies = TRUE, quiet = TRUE), - # message = function(m) invisible(), - warning = function(w) message(w$message), - error = function(e) message(e$message)) - } + cat("Installing package", to_install[i], "\n") + tryCatch(install.packages(to_install[i], repos = "https://cran.rstudio.com/", dependencies = TRUE, quiet = TRUE), + # message = function(m) invisible(), + warning = function(w) message(w$message), + error = function(e) message(e$message)) } for (i in seq_len(length(to_update))) { - if (isTRUE(is.character(to_update[i]))) { - cat("Updating package", to_update[i], "\n") - tryCatch(update.packages(to_update[i], repos = "https://cran.rstudio.com/", ask = FALSE), - # message = function(m) invisible(), - warning = function(w) message(w$message), - error = function(e) message(e$message)) - } + cat("Updating package", to_update[i], "\n") + tryCatch(update.packages(to_update[i], repos = "https://cran.rstudio.com/", ask = FALSE), + # message = function(m) invisible(), + warning = function(w) message(w$message), + error = function(e) message(e$message)) } diff --git a/docs/404.html b/docs/404.html index 9d728adf..7ebba78c 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9049 + 1.6.0.9050 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index ce5b405d..607ff1b5 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9049 + 1.6.0.9050 diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 345f4066..39339b9e 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.6.0.9049 + 1.6.0.9050 @@ -192,7 +192,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 8d5804ce..7f7da5c5 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9049 + 1.6.0.9050 diff --git a/docs/index.html b/docs/index.html index b57d08ae..45d37b8c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 1.6.0.9049 + 1.6.0.9050 diff --git a/docs/news/index.html b/docs/news/index.html index 6b3b0946..cd254c5b 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9049 + 1.6.0.9050 @@ -236,12 +236,12 @@ Source: NEWS.md -
-

- Unreleased AMR 1.6.0.9049

-
+
+

+ Unreleased AMR 1.6.0.9050

+

-Last updated: 19 May 2021 +Last updated: 20 May 2021

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 1fa87d64..9f57ff13 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -12,7 +12,7 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2021-05-19T21:58Z +last_built: 2021-05-20T08:10Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/atc_online.html b/docs/reference/atc_online.html index 0976037d..5d4653ca 100644 --- a/docs/reference/atc_online.html +++ b/docs/reference/atc_online.html @@ -82,7 +82,7 @@ AMR (for R) - 1.6.0.9021 + 1.6.0.9050

@@ -309,7 +309,7 @@
  • "TU" = thousand units

  • "MU" = million units

  • "mmol" = millimole

  • -
  • "ml" = milliliter (e.g. eyedrops)

  • +
  • "ml" = millilitre (e.g. eyedrops)

  • N.B. This function requires an internet connection and only works if the following packages are installed: curl, rvest, xml2.

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 2b430678..63a3578e 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9049 + 1.6.0.9050
    diff --git a/docs/survey.html b/docs/survey.html index c1c4492e..4fbf51a0 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9049 + 1.6.0.9050
    diff --git a/inst/tinytest/test-atc_online.R b/inst/tinytest/test-atc_online.R index bd390e1a..9feaf261 100644 --- a/inst/tinytest/test-atc_online.R +++ b/inst/tinytest/test-atc_online.R @@ -23,7 +23,10 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -if (tryCatch(curl::has_internet(), error = function(e) FALSE)) { +if (pkg_is_available("curl", also_load = FALSE) && + pkg_is_available("rvest", also_load = FALSE) && + pkg_is_available("xml2", also_load = FALSE) && + tryCatch(curl::has_internet(), error = function(e) FALSE)) { expect_true(length(atc_online_groups(ab_atc("AMX"))) >= 1) expect_equal(atc_online_ddd(ab_atc("AMX"), administration = "O"), 1.5) expect_equal(atc_online_ddd(ab_atc("AMX"), administration = "P"), 3) diff --git a/inst/tinytest/test-proportion.R b/inst/tinytest/test-proportion.R index 93927483..5f2b7d34 100755 --- a/inst/tinytest/test-proportion.R +++ b/inst/tinytest/test-proportion.R @@ -35,17 +35,17 @@ expect_equal(proportion_R(example_isolates$AMX) + proportion_I(example_isolates$ expect_equal(proportion_S(example_isolates$AMX) + proportion_I(example_isolates$AMX), proportion_SI(example_isolates$AMX)) -expect_equal(example_isolates %>% proportion_SI(AMC), - 0.7626397, - tolerance = 0.0001) -expect_equal(example_isolates %>% proportion_SI(AMC, GEN), - 0.9408, - tolerance = 0.0001) -expect_equal(example_isolates %>% proportion_SI(AMC, GEN, only_all_tested = TRUE), - 0.9382647, - tolerance = 0.0001) - if (pkg_is_available("dplyr")) { + expect_equal(example_isolates %>% proportion_SI(AMC), + 0.7626397, + tolerance = 0.0001) + expect_equal(example_isolates %>% proportion_SI(AMC, GEN), + 0.9408, + tolerance = 0.0001) + expect_equal(example_isolates %>% proportion_SI(AMC, GEN, only_all_tested = TRUE), + 0.9382647, + tolerance = 0.0001) + # percentages expect_equal(example_isolates %>% group_by(hospital_id) %>% diff --git a/man/atc_online.Rd b/man/atc_online.Rd index b62a582a..190b4cfe 100644 --- a/man/atc_online.Rd +++ b/man/atc_online.Rd @@ -61,7 +61,7 @@ Abbreviations of return values when using \code{property = "U"} (unit): \item \code{"TU"} = thousand units \item \code{"MU"} = million units \item \code{"mmol"} = millimole -\item \code{"ml"} = milliliter (e.g. eyedrops) +\item \code{"ml"} = millilitre (e.g. eyedrops) } \strong{N.B. This function requires an internet connection and only works if the following packages are installed: \code{curl}, \code{rvest}, \code{xml2}.}