diff --git a/.github/workflows/codecovr.yaml b/.github/workflows/codecovr.yaml index 38a0f177..9871c13b 100644 --- a/.github/workflows/codecovr.yaml +++ b/.github/workflows/codecovr.yaml @@ -68,16 +68,28 @@ jobs: as.data.frame(utils::installed.packages())[, "Version", drop = FALSE] shell: Rscript {0} + # - name: Test coverage + # env: + # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + # run: | + # library(AMR) + # library(tinytest) + # library(covr) + # source_files <- list.files("R", pattern = ".R$", full.names = TRUE) + # test_files <- list.files("inst/tinytest", full.names = TRUE) + # cov <- file_coverage(source_files = source_files, test_files = test_files, parent_env = asNamespace("AMR"), line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R")) + # attr(cov, which = "package") <- list(path = ".") # until https://github.com/r-lib/covr/issues/478 is solved + # codecov(coverage = cov, quiet = FALSE) + # shell: Rscript {0} + - name: Test coverage env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + R_RUN_TINYTEST: true run: | library(AMR) library(tinytest) - library(covr) - source_files <- list.files("R", pattern = ".R$", full.names = TRUE) - test_files <- list.files("inst/tinytest", full.names = TRUE) - cov <- file_coverage(source_files = source_files, test_files = test_files, parent_env = asNamespace("AMR"), line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R")) - attr(cov, which = "package") <- list(path = ".") # until https://github.com/r-lib/covr/issues/478 is solved - codecov(coverage = cov, quiet = FALSE) + covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R")) shell: Rscript {0} + + diff --git a/DESCRIPTION b/DESCRIPTION index 3806104e..9187fe63 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.6.0.9065 +Version: 1.7.0 Date: 2021-05-24 Title: Antimicrobial Resistance Data Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index af61cdf7..690d0526 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# `AMR` 1.6.0.9065 -## Last updated: 24 May 2021 +# `AMR` 1.7.0 + ### 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. @@ -906,7 +906,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git * Emphasised in manual that penicillin is meant as benzylpenicillin (ATC [J01CE01](https://www.whocc.no/atc_ddd_index/?code=J01CE01)) * New info is returned when running this function, stating exactly what has been changed or added. Use `eucast_rules(..., verbose = TRUE)` to get a data set with all changed per bug and drug combination. * Removed data sets `microorganisms.oldDT`, `microorganisms.prevDT`, `microorganisms.unprevDT` and `microorganismsDT` since they were no longer needed and only contained info already available in the `microorganisms` data set -* Added 65 antibiotics to the `antibiotics` data set, from the [Pharmaceuticals Community Register](http://ec.europa.eu/health/documents/community-register/html/atc.htm) of the European Commission +* Added 65 antibiotics to the `antibiotics` data set, from the [Pharmaceuticals Community Register](https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm) of the European Commission * Removed columns `atc_group1_nl` and `atc_group2_nl` from the `antibiotics` data set * Functions `atc_ddd()` and `atc_groups()` have been renamed `atc_online_ddd()` and `atc_online_groups()`. The old functions are deprecated and will be removed in a future version. * Function `guess_mo()` is now deprecated in favour of `as.mo()` and will be removed in future versions diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 035cc239..17f2a05a 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -192,7 +192,7 @@ search_type_in_df <- function(x, type, info = TRUE) { } # -- key antibiotics - if (type == "keyantibiotics") { + if (type %in% c("keyantibiotics", "keyantimicrobials")) { if (any(colnames(x) %like% "^key.*(ab|antibiotics|antimicrobials)")) { found <- sort(colnames(x)[colnames(x) %like% "^key.*(ab|antibiotics|antimicrobials)"])[1] } @@ -865,7 +865,7 @@ unique_call_id <- function(entire_session = FALSE) { # combination of environment ID (like "0x7fed4ee8c848") # and highest system call call <- paste0(deparse(sys.calls()[[1]]), collapse = "") - if (call %like% "run_test_dir|test_all|tinytest|test_package|testthat") { + if (!interactive() || call %like% "run_test_dir|test_all|tinytest|test_package|testthat") { # unit tests will keep the same call and environment - give them a unique ID call <- paste0(sample(c(c(0:9), letters[1:6]), size = 64, replace = TRUE), collapse = "") } @@ -1122,7 +1122,7 @@ s3_register <- function(generic, class, method = NULL) { # works exactly like round(), but rounds `round2(44.55, 1)` to 44.6 instead of 44.5 # and adds decimal zeroes until `digits` is reached when force_zero = TRUE -round2 <- function(x, digits = 0, force_zero = TRUE) { +round2 <- function(x, digits = 1, force_zero = TRUE) { x <- as.double(x) # https://stackoverflow.com/a/12688836/4575331 val <- (trunc((abs(x) * 10 ^ digits) + 0.5) / 10 ^ digits) * sign(x) @@ -1174,7 +1174,7 @@ percentage <- function(x, digits = NULL, ...) { # round right: percentage(0.4455) and format(as.percentage(0.4455), 1) should return "44.6%", not "44.5%" x_formatted <- format(round2(as.double(x), digits = digits + 2) * 100, scientific = FALSE, - digits = digits, + digits = max(1, digits), nsmall = digits, ...) x_formatted <- paste0(x_formatted, "%") diff --git a/R/ab.R b/R/ab.R index 9297d3ab..c8a4fdcf 100755 --- a/R/ab.R +++ b/R/ab.R @@ -50,7 +50,7 @@ #' #' WHONET 2019 software: \url{http://www.whonet.org/software.html} #' -#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{http://ec.europa.eu/health/documents/community-register/html/atc.htm} +#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{https://ec.europa.eu/health/documents/community-register/html/reg_hum_atc.htm} #' @aliases ab #' @return A [character] [vector] with additional class [`ab`] #' @seealso diff --git a/R/data.R b/R/data.R index 8d6f8473..05aaaa35 100755 --- a/R/data.R +++ b/R/data.R @@ -71,7 +71,7 @@ #' #' WHONET 2019 software: #' -#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: +#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: #' @inheritSection AMR Reference Data Publicly Available #' @inheritSection WHOCC WHOCC #' @inheritSection AMR Read more on Our Website! diff --git a/R/first_isolate.R b/R/first_isolate.R index 432ab98d..c6e7f9c2 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -273,7 +273,7 @@ first_isolate <- function(x = NULL, # try to find columns based on type # -- mo if (is.null(col_mo)) { - col_mo <- search_type_in_df(x = x, type = "mo") + col_mo <- search_type_in_df(x = x, type = "mo", info = info) stop_if(is.null(col_mo), "`col_mo` must be set") } @@ -299,7 +299,7 @@ first_isolate <- function(x = NULL, x$keyantimicrobials <- all_antimicrobials(x, only_rsi_columns = FALSE) col_keyantimicrobials <- "keyantimicrobials" } else if (type == "keyantimicrobials" & is.null(col_keyantimicrobials)) { - col_keyantimicrobials <- search_type_in_df(x = x, type = "keyantibiotics") + col_keyantimicrobials <- search_type_in_df(x = x, type = "keyantimicrobials", info = info) if (is.null(col_keyantimicrobials)) { # still not found as a column, create it ourselves x$keyantimicrobials <- key_antimicrobials(x, only_rsi_columns = FALSE, col_mo = col_mo, ...) @@ -310,7 +310,7 @@ first_isolate <- function(x = NULL, # -- date if (is.null(col_date)) { - col_date <- search_type_in_df(x = x, type = "date") + col_date <- search_type_in_df(x = x, type = "date", info = info) stop_if(is.null(col_date), "`col_date` must be set") } @@ -322,14 +322,14 @@ first_isolate <- function(x = NULL, col_patient_id <- "patient_id" message_("Using combined columns '", font_bold("First name"), "', '", font_bold("Last name"), "' and '", font_bold("Sex"), "' as input for `col_patient_id`") } else { - col_patient_id <- search_type_in_df(x = x, type = "patient_id") + col_patient_id <- search_type_in_df(x = x, type = "patient_id", info = info) } stop_if(is.null(col_patient_id), "`col_patient_id` must be set") } # -- specimen if (is.null(col_specimen) & !is.null(specimen_group)) { - col_specimen <- search_type_in_df(x = x, type = "specimen") + col_specimen <- search_type_in_df(x = x, type = "specimen", info = info) } # check if columns exist diff --git a/R/rsi.R b/R/rsi.R index 02001340..e74d67d1 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -215,7 +215,6 @@ is.rsi.eligible <- function(x, threshold = 0.05) { "ab", "Date", "POSIXt", - "rsi", "raw", "hms", "mic", diff --git a/R/whocc.R b/R/whocc.R index af27dc70..3da7abe5 100755 --- a/R/whocc.R +++ b/R/whocc.R @@ -28,7 +28,7 @@ #' All antimicrobial drugs and their official names, ATC codes, ATC groups and defined daily dose (DDD) are included in this package, using the WHO Collaborating Centre for Drug Statistics Methodology. #' @section WHOCC: #' \if{html}{\figure{logo_who.png}{options: height=60px style=margin-bottom:5px} \cr} -#' This package contains **all ~550 antibiotic, antimycotic and antiviral drugs** and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, ) and the Pharmaceuticals Community Register of the European Commission (). +#' This package contains **all ~550 antibiotic, antimycotic and antiviral drugs** and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, ) and the Pharmaceuticals Community Register of the European Commission (). #' #' These have become the gold standard for international drug utilisation monitoring and research. #' diff --git a/cran-comments.md b/cran-comments.md index 102f952b..3093395e 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,3 @@ -* This package has been archived on 22 May 2021 because of errors in the dplyr package, causing the skimr package to fail: . This AMR package contains a fix around this error. Nonetheless, an automated email sent to the maintainer with a warning that the AMR package would be archived would have saved us this archiving. Perhaps an idea for future development of CRAN? +* This package has been archived on 22 May 2021 because of errors in the dplyr package, causing the skimr package to fail: . This AMR package contains a fix around this error. Perhaps an idea for future development of CRAN to send an automated email to a maintainer with a warning that a package will be archived in due time? * This package continuously has a tarball size of over 7 MB and an installation size of over 5 MB, which will return a NOTE on R CMD CHECK. This has been the case in the last releases as well. The package size is needed to offer users reference data for the complete taxonomy of microorganisms - one of the most important features of this package. This was written and explained in a manuscript that was accepted for publication in the Journal of Statistical Software earlier this year. We will add the paper as a vignette after publication in a next version. All data sets were compressed using `compression = "xz"` to make them as small as possible. diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index f769346f..635da6bf 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/docs/404.html b/docs/404.html index 287410c4..c35ff6d9 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9065 + 1.7.0 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index a6bcb473..d9619e59 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9065 + 1.7.0 diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 72631b3e..c57448a3 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -39,7 +39,7 @@ AMR (for R) - 1.6.0.9011 + 1.7.0 @@ -47,14 +47,14 @@