diff --git a/DESCRIPTION b/DESCRIPTION index bf6cc0be..0e3944fc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.6.0.9063 +Version: 1.6.0.9064 Date: 2021-05-24 Title: Antimicrobial Resistance Data Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index e1940676..c6c5ee0a 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# `AMR` 1.6.0.9063 +# `AMR` 1.6.0.9064 ## Last updated: 24 May 2021 ### Breaking change diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index adbb3454..1411b022 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -716,6 +716,11 @@ meet_criteria <- function(object, } get_current_data <- function(arg_name, call) { + # check if retrieved before, then get it from package environment + if (identical(unique_call_id(entire_session = FALSE), pkg_env$get_current_data.call)) { + return(pkg_env$get_current_data.out) + } + # try dplyr::cur_data_all() first to support dplyr groups # only useful for e.g. dplyr::filter(), dplyr::mutate() and dplyr::summarise() # not useful (throws error) with e.g. dplyr::select() - but that will be caught later in this function @@ -723,7 +728,10 @@ get_current_data <- function(arg_name, call) { if (!is.null(cur_data_all)) { out <- tryCatch(cur_data_all(), error = function(e) NULL) if (is.data.frame(out)) { - return(structure(out, type = "dplyr_cur_data_all")) + out <- structure(out, type = "dplyr_cur_data_all") + pkg_env$get_current_data.call <- unique_call_id(entire_session = FALSE) + pkg_env$get_current_data.out <- out + return(out) } } @@ -779,7 +787,10 @@ get_current_data <- function(arg_name, call) { # lookup the matched frame and return its value: a data.frame vars_df <- tryCatch(frms[[which(!vapply(FUN.VALUE = logical(1), frms, is.null))]], error = function(e) NULL) if (is.data.frame(vars_df)) { - return(structure(vars_df, type = source)) + out <- structure(vars_df, type = source) + pkg_env$get_current_data.call <- unique_call_id(entire_session = FALSE) + pkg_env$get_current_data.out <- out + return(out) } # nothing worked, so: diff --git a/R/ab_class_selectors.R b/R/ab_class_selectors.R index 0e63fae2..ce103cb6 100644 --- a/R/ab_class_selectors.R +++ b/R/ab_class_selectors.R @@ -228,16 +228,9 @@ ab_selector <- function(ab_class, return(NULL) } + # to improve speed, get_current_data() and get_column_abx() only run once when e.g. in a select or group call vars_df <- get_current_data(arg_name = NA, call = -3) - - # improve speed here so it will only run once when e.g. in one select call - if (!identical(pkg_env$ab_selector, unique_call_id())) { - ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns, sort = FALSE) - pkg_env$ab_selector <- unique_call_id() - pkg_env$ab_selector_cols <- ab_in_data - } else { - ab_in_data <- pkg_env$ab_selector_cols - } + ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns, sort = FALSE) if (length(ab_in_data) == 0) { message_("No antimicrobial agents found.") diff --git a/R/atc_online.R b/R/atc_online.R index 9a4709aa..e04f6c75 100644 --- a/R/atc_online.R +++ b/R/atc_online.R @@ -64,14 +64,16 @@ #' @inheritSection AMR Read more on Our Website! #' @source #' @examples -#' \dontrun{ -#' # oral DDD (Defined Daily Dose) of amoxicillin -#' atc_online_property("J01CA04", "DDD", "O") +#' \donttest{ +#' if (requireNamespace("curl") && requireNamespace("rvest") && requireNamespace("xml2")) { +#' # oral DDD (Defined Daily Dose) of amoxicillin +#' atc_online_property("J01CA04", "DDD", "O") #' -#' # parenteral DDD (Defined Daily Dose) of amoxicillin -#' atc_online_property("J01CA04", "DDD", "P") +#' # parenteral DDD (Defined Daily Dose) of amoxicillin +#' atc_online_property("J01CA04", "DDD", "P") #' -#' atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin +#' atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin +#' } #' } atc_online_property <- function(atc_code, property, diff --git a/R/guess_ab_col.R b/R/guess_ab_col.R index c085fc1f..e8ddeec7 100755 --- a/R/guess_ab_col.R +++ b/R/guess_ab_col.R @@ -104,6 +104,12 @@ get_column_abx <- function(x, only_rsi_columns = FALSE, sort = TRUE, ...) { + + # check if retrieved before, then get it from package environment + if (identical(unique_call_id(entire_session = FALSE), pkg_env$get_column_abx.call)) { + return(pkg_env$get_column_abx.out) + } + meet_criteria(x, allow_class = "data.frame") meet_criteria(soft_dependencies, allow_class = "character", allow_NULL = TRUE) meet_criteria(hard_dependencies, allow_class = "character", allow_NULL = TRUE) @@ -184,6 +190,8 @@ get_column_abx <- function(x, if (info == TRUE) { message_("No columns found.") } + pkg_env$get_column_abx.call <- unique_call_id(entire_session = FALSE) + pkg_env$get_column_abx.out <- x return(x) } @@ -239,6 +247,9 @@ get_column_abx <- function(x, missing_msg) } } + + pkg_env$get_column_abx.call <- unique_call_id(entire_session = FALSE) + pkg_env$get_column_abx.out <- x x } diff --git a/cran-comments.md b/cran-comments.md index 80a60592..102f952b 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 a tarball size of over 7 MB and an installation size of over 5 MB, which will return a NOTE on R CMD CHECK. 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 4 weeks ago. We will add the paper as a vignette in the next version. Please allow this exception in package size for CRAN. We already compressed all data sets using `compression = "xz"` to make them as small as possible. +* 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 65d7e478..d155cdc3 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 407d155c..96109e99 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9063 + 1.6.0.9064 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 74834e13..7161b151 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9063 + 1.6.0.9064 diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 1792c21d..14fb93f4 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.6.0.9063 + 1.6.0.9064 diff --git a/docs/articles/index.html b/docs/articles/index.html index c056d918..b4f0d5b1 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9063 + 1.6.0.9064 diff --git a/docs/authors.html b/docs/authors.html index da9235de..b2bf94df 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9063 + 1.6.0.9064 diff --git a/docs/index.html b/docs/index.html index ebda3708..84867edc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 1.6.0.9063 + 1.6.0.9064 diff --git a/docs/news/index.html b/docs/news/index.html index 05ece7a0..a6a600b3 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9063 + 1.6.0.9064 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

- Unreleased AMR 1.6.0.9063

+
+

+ Unreleased AMR 1.6.0.9064

Last updated: 24 May 2021 @@ -288,7 +288,7 @@
  • Function betalactams() as additional antbiotic column selector and function filter_betalactams() as additional antbiotic column filter. The group of betalactams consists of all carbapenems, cephalosporins and penicillins.
  • -
  • A ggplot() method for resistance_predict() +
  • A ggplot() method for resistance_predict()
  • @@ -387,7 +387,7 @@ #> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"
  • Support for custom MDRO guidelines, using the new custom_mdro_guideline() function, please see mdro() for additional info

  • -
  • ggplot() generics for classes <mic> and <disk>

  • +
  • ggplot() generics for classes <mic> and <disk>

  • Function mo_is_yeast(), which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:

    @@ -444,7 +444,7 @@
     
  • Plotting of MIC and disk diffusion values now support interpretation colouring if you supply the microorganism and antimicrobial agent
  • All colours were updated to colour-blind friendly versions for values R, S and I for all plot methods (also applies to tibble printing)
  • Interpretation of MIC and disk diffusion values to R/SI will now be translated if the system language is German, Dutch or Spanish (see translate)
  • -
  • Plotting is now possible with base R using plot() and with ggplot2 using ggplot() on any vector of MIC and disk diffusion values
  • +
  • Plotting is now possible with base R using plot() and with ggplot2 using ggplot() on any vector of MIC and disk diffusion values
  • Updated SNOMED codes to US Edition of SNOMED CT from 1 September 2020 and added the source to the help page of the microorganisms data set
  • @@ -461,7 +461,7 @@ is.rsi.eligible() now detects if the column name resembles an antibiotic name or code and now returns TRUE immediately if the input contains any of the values “R”, “S” or “I”. This drastically improves speed, also for a lot of other functions that rely on automatic determination of antibiotic columns.
  • Functions get_episode() and is_new_episode() now support less than a day as value for argument episode_days (e.g., to include one patient/test per hour)
  • Argument ampc_cephalosporin_resistance in eucast_rules() now also applies to value “I” (not only “S”)
  • -
  • Functions print() and summary() on a Principal Components Analysis object (pca()) now print additional group info if the original data was grouped using dplyr::group_by() +
  • Functions print() and summary() on a Principal Components Analysis object (pca()) now print additional group info if the original data was grouped using dplyr::group_by()
  • Improved speed and reliability of guess_ab_col(). As this also internally improves the reliability of first_isolate() and mdro(), this might have a slight impact on the results of those functions.
  • Fix for mo_name() when used in other languages than English
  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 015f95e8..9a7f96cd 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-24T06:56Z +last_built: 2021-05-24T07:33Z 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 dee60e49..6632c63e 100644 --- a/docs/reference/atc_online.html +++ b/docs/reference/atc_online.html @@ -82,7 +82,7 @@ AMR (for R) - 1.6.0.9063 + 1.6.0.9064
    @@ -327,15 +327,17 @@ The lifecycle of this function is stableOn our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR data analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

    Examples

    -
    if (FALSE) {
    -# oral DDD (Defined Daily Dose) of amoxicillin
    -atc_online_property("J01CA04", "DDD", "O")
    +    
    # \donttest{
    +if (requireNamespace("curl") && requireNamespace("rvest") && requireNamespace("xml2")) { 
    +  # oral DDD (Defined Daily Dose) of amoxicillin
    +  atc_online_property("J01CA04", "DDD", "O")
     
    -# parenteral DDD (Defined Daily Dose) of amoxicillin
    -atc_online_property("J01CA04", "DDD", "P")
    +  # parenteral DDD (Defined Daily Dose) of amoxicillin
    +  atc_online_property("J01CA04", "DDD", "P")
     
    -atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
    +  atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
     }
    +# }
     
    diff --git a/docs/survey.html b/docs/survey.html index 0a881372..1b504005 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9063 + 1.6.0.9064 diff --git a/man/atc_online.Rd b/man/atc_online.Rd index 2e02f580..02b2c33f 100644 --- a/man/atc_online.Rd +++ b/man/atc_online.Rd @@ -80,13 +80,15 @@ On our website \url{https://msberends.github.io/AMR/} you can find \href{https:/ } \examples{ -\dontrun{ -# oral DDD (Defined Daily Dose) of amoxicillin -atc_online_property("J01CA04", "DDD", "O") +\donttest{ +if (requireNamespace("curl") && requireNamespace("rvest") && requireNamespace("xml2")) { + # oral DDD (Defined Daily Dose) of amoxicillin + atc_online_property("J01CA04", "DDD", "O") -# parenteral DDD (Defined Daily Dose) of amoxicillin -atc_online_property("J01CA04", "DDD", "P") + # parenteral DDD (Defined Daily Dose) of amoxicillin + atc_online_property("J01CA04", "DDD", "P") -atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin + atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin +} } } diff --git a/tests/tinytest.R b/tests/tinytest.R index 57d0c555..86f63498 100644 --- a/tests/tinytest.R +++ b/tests/tinytest.R @@ -36,5 +36,6 @@ if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) { verbose = FALSE) cat(attributes(out)$duration, "\n") print(summary(out)) + print(warnings()) } }