From 29609a0e2c6695ca09337dc99b16142c7095c8a2 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Sat, 16 May 2020 20:42:45 +0200 Subject: [PATCH] (v1.1.0.9006) lose dependencies --- .gitlab-ci.yml | 2 + DESCRIPTION | 2 +- NEWS.md | 2 +- R/aa_helper_functions.R | 10 ++-- R/atc_online.R | 14 ++++-- R/ggplot_rsi.R | 77 ++++++++++++++-------------- docs/news/index.html | 86 +++++++++++++++++++------------- tests/appveyor/appveyor_tool.ps1 | 2 +- 8 files changed, 109 insertions(+), 86 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6a9f0c00..b7127048 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,6 +62,7 @@ R-release: allow_failure: false script: - Rscript -e 'sessionInfo()' + - Rscript -e 'AMR::eucast_rules(AMR::example_isolates_unclean, info = TRUE)' # install missing and outdated packages - Rscript -e 'source(".gitlab-ci.R"); gl_update_pkg_all(repos = "https://cran.rstudio.com", quiet = TRUE, install_pkgdown = TRUE, install_lintr = TRUE)' - Rscript -e 'devtools::test(stop_on_failure = FALSE)' @@ -77,6 +78,7 @@ R-devel: allow_failure: false script: - Rscriptdevel -e 'sessionInfo()' + - Rscriptdevel -e 'AMR::eucast_rules(AMR::example_isolates_unclean, info = TRUE)' # install missing and outdated packages - Rscriptdevel -e 'source(".gitlab-ci.R"); gl_update_pkg_all(repos = "https://cran.rstudio.com", quiet = TRUE, install_pkgdown = TRUE, install_lintr = TRUE)' - Rscriptdevel -e 'devtools::test(stop_on_failure = FALSE)' diff --git a/DESCRIPTION b/DESCRIPTION index 8416b237..c41350f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.1.0.9005 +Version: 1.1.0.9006 Date: 2020-05-16 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index fce08c36..ee4e81ae 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.1.0.9005 +# AMR 1.1.0.9006 ## Last updated: 16-May-2020 ### Breaking diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 1bff1aca..a0232f69 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -63,16 +63,14 @@ filter_join_worker <- function(x, y, by = NULL, type = c("anti", "semi")) { # No export, no Rd addin_insert_in <- function() { - if (!require("rstudioapi")) { - insertText(" %in% ") - } + stopifnot_installed_package("rstudioapi") + get("insertText", envir = asNamespace("rstudioapi"))(" %in% ") } # No export, no Rd addin_insert_like <- function() { - if (!require("rstudioapi")) { - insertText(" %like% ") - } + stopifnot_installed_package("rstudioapi") + get("insertText", envir = asNamespace("rstudioapi"))(" %like% ") } check_dataset_integrity <- function() { diff --git a/R/atc_online.R b/R/atc_online.R index 9ef534c7..0b056755 100644 --- a/R/atc_online.R +++ b/R/atc_online.R @@ -59,7 +59,7 @@ #' @inheritSection AMR Read more on our website! #' @source #' @examples -#' \donttest{ +#' \dontrun{ #' # oral DDD (Defined Daily Dose) of amoxicillin #' atc_online_property("J01CA04", "DDD", "O") #' # parenteral DDD (Defined Daily Dose) of amoxicillin @@ -77,6 +77,14 @@ atc_online_property <- function(atc_code, url = "https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no") { stopifnot_installed_package(c("curl", "rvest", "xml2")) + has_internet <- get("has_internet", envir = asNamespace("curl")) + html_attr <- get("html_attr", envir = asNamespace("rvest")) + html_children <- get("html_children", envir = asNamespace("rvest")) + html_node <- get("html_node", envir = asNamespace("rvest")) + html_nodes <- get("html_nodes", envir = asNamespace("rvest")) + html_table <- get("html_table", envir = asNamespace("rvest")) + html_text <- get("html_text", envir = asNamespace("rvest")) + read_html <- get("read_html", envir = asNamespace("xml2")) check_dataset_integrity() @@ -84,10 +92,6 @@ atc_online_property <- function(atc_code, atc_code <- as.character(ab_atc(atc_code)) } - require("curl") - require("xml2") - require("rvest") - if (!has_internet()) { message("There appears to be no internet connection.") return(rep(NA, length(atc_code))) diff --git a/R/ggplot_rsi.R b/R/ggplot_rsi.R index d4c8b627..2b3280aa 100755 --- a/R/ggplot_rsi.R +++ b/R/ggplot_rsi.R @@ -62,44 +62,45 @@ #' @export #' @inheritSection AMR Read more on our website! #' @examples -#' library(dplyr) -#' library(ggplot2) -#' -#' # get antimicrobial results for drugs against a UTI: -#' ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) + -#' geom_rsi() -#' -#' # prettify the plot using some additional functions: -#' df <- example_isolates %>% select(AMX, NIT, FOS, TMP, CIP) -#' ggplot(df) + -#' geom_rsi() + -#' scale_y_percent() + -#' scale_rsi_colours() + -#' labels_rsi_count() + -#' theme_rsi() -#' -#' # or better yet, simplify this using the wrapper function - a single command: -#' example_isolates %>% -#' select(AMX, NIT, FOS, TMP, CIP) %>% -#' ggplot_rsi() -#' -#' # get only proportions and no counts: -#' example_isolates %>% -#' select(AMX, NIT, FOS, TMP, CIP) %>% -#' ggplot_rsi(datalabels = FALSE) -#' -#' # add other ggplot2 parameters as you like: -#' example_isolates %>% -#' select(AMX, NIT, FOS, TMP, CIP) %>% -#' ggplot_rsi(width = 0.5, -#' colour = "black", -#' size = 1, -#' linetype = 2, -#' alpha = 0.25) -#' -#' example_isolates %>% -#' select(AMX) %>% -#' ggplot_rsi(colours = c(SI = "yellow")) +#' if (!require("ggplot2") & !require("dplyr")) { +#' +#' # get antimicrobial results for drugs against a UTI: +#' ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) + +#' geom_rsi() +#' +#' # prettify the plot using some additional functions: +#' df <- example_isolates %>% select(AMX, NIT, FOS, TMP, CIP) +#' ggplot(df) + +#' geom_rsi() + +#' scale_y_percent() + +#' scale_rsi_colours() + +#' labels_rsi_count() + +#' theme_rsi() +#' +#' # or better yet, simplify this using the wrapper function - a single command: +#' example_isolates %>% +#' select(AMX, NIT, FOS, TMP, CIP) %>% +#' ggplot_rsi() +#' +#' # get only proportions and no counts: +#' example_isolates %>% +#' select(AMX, NIT, FOS, TMP, CIP) %>% +#' ggplot_rsi(datalabels = FALSE) +#' +#' # add other ggplot2 parameters as you like: +#' example_isolates %>% +#' select(AMX, NIT, FOS, TMP, CIP) %>% +#' ggplot_rsi(width = 0.5, +#' colour = "black", +#' size = 1, +#' linetype = 2, +#' alpha = 0.25) +#' +#' example_isolates %>% +#' select(AMX) %>% +#' ggplot_rsi(colours = c(SI = "yellow")) +#' +#' } #' #' \dontrun{ #' diff --git a/docs/news/index.html b/docs/news/index.html index 750b6c1c..b28dece7 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9003 + 1.1.0.9006 @@ -229,21 +229,39 @@ Source: NEWS.md -
-

-AMR 1.1.0.9003 Unreleased +
+

+AMR 1.1.0.9006 Unreleased

-
+

-Last updated: 01-May-2020 +Last updated: 16-May-2020

+
+

+Breaking

+
    +
  • Removed previously deprecated function p.symbol() - it was replaced with p_symbol() +
  • +
+

Changed

  • Small fix for some text input that could not be coerced as valid MIC values
  • -
  • Better support for the tidyverse. The tidyverse now heavily relies on the vctrs package for data transformation and data joining. In newer versions of e.g. the dplyr package, a function like bind_rows() would not preserve the right class for microorganisms (class mo) and antibiotics (class ab). This is fixed in this version.
  • +
  • Fix for cases where some functions of newer versions of the dplyr package (such as bind_rows()) would not preserve the right class for microorganisms (class mo) and antibiotics (class ab)
  • Fixed interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood)
  • +
  • Added official drug names to verbose output of eucast_rules() +
  • +
+
+
+

+Other

+
    +
  • Removed dependency on all packages that were needed for the AMR package to work properly: crayon, data.table, dplyr, ggplot2, R6, rlang and tidyr. This is a major code change, but will probably not be noticeable by users. Making this package independent on especially the tidyverse (packages dplyr, ggplot2 and tidyr) tremendously increases sustainability on the long term, since tidyverse functions change quite often. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. The only dependencies that remained are for extending methods of other packages, like pillar and vctrs for printing and working with tibbles using our classes mo and ab.
  • +
  • Removed function read.4d(), that was only useful for reading from an old test database.
@@ -280,9 +298,9 @@
  • Added generic CLSI rules for R/SI interpretation using as.rsi() for years 2010-2019 (thanks to Anthony Underwood)
  • -
    +

    -Other

    +Other

    • Support for the upcoming dplyr version 1.0.0
    • More robust assigning for classes rsi and mic @@ -378,9 +396,9 @@
    -
    +

    -Other

    +Other
    • Add a CITATION file
    • Full support for the upcoming R 4.0
    • @@ -392,9 +410,9 @@

      AMR 0.9.0 2019-11-29

      -
      +

      -Breaking

      +Breaking
      • Adopted Adeolu et al. (2016), PMID 27620848 for the microorganisms data set, which means that the new order Enterobacterales now consists of a part of the existing family Enterobacteriaceae, but that this family has been split into other families as well (like Morganellaceae and Yersiniaceae). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with mdro() will now use the Enterobacterales order for all guidelines before 2016 that were dependent on the Enterobacteriaceae family.
          @@ -477,9 +495,9 @@
      -
      +

      -Other

      +Other
      • Rewrote the complete documentation to markdown format, to be able to use the very latest version of the great Roxygen2, released in November 2019. This tremously improved the documentation quality, since the rewrite forced us to go over all texts again and make changes where needed.
      • Change dependency on clean to cleaner, as this package was renamed accordingly upon CRAN request
      • @@ -491,9 +509,9 @@

        AMR 0.8.0 2019-10-15

        -
        +

        -Breaking

        +Breaking
        • Determination of first isolates now excludes all ‘unknown’ microorganisms at default, i.e. microbial code "UNKNOWN". They can be included with the new parameter include_unknown:

          @@ -619,7 +637,7 @@ Since this is a major change, usage of the old also_single_tested w
        • Improved filter_ab_class() to be more reliable and to support 5th generation cephalosporins
        • Function availability() now uses portion_R() instead of portion_IR(), to comply with EUCAST insights
        • Functions age() and age_groups() now have a na.rm parameter to remove empty values
        • -
        • Renamed function p.symbol() to p_symbol() (the former is now deprecated and will be removed in a future version)
        • +
        • Renamed function p.symbol() to p_symbol() (the former is now deprecated and will be removed in a future version)
        • Using negative values for x in age_groups() will now introduce NAs and not return an error anymore
        • Fix for determining the system’s language
        • Fix for key_antibiotics() on foreign systems
        • @@ -628,9 +646,9 @@ Since this is a major change, usage of the old also_single_tested w
        • Added more MIC factor levels (as.mic())
        -
        +

        -Other

        +Other
        • Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors
        • Cleaned the coding style of every single syntax line in this package with the help of the lintr package
        • @@ -711,9 +729,9 @@ Since this is a major change, usage of the old also_single_tested w
        -
        +

        -Other

        +Other
        • Fixed a note thrown by CRAN tests
        @@ -807,9 +825,9 @@ Please mo_shortname() where species would not be determined correctly

      -
      +

      -Other

      +Other
      -
      +

      -Other

      +Other
      • Updated licence text to emphasise GPL 2.0 and that this is an R package.
      @@ -1180,9 +1198,9 @@ Using as.mo(..., allow_uncertain = 3)

      Percentages will now will rounded more logically (e.g. in freq function)

    -
    +

    -Other

    +Other
    • New dependency on package crayon, to support formatted text in the console
    • Dependency tidyr is now mandatory (went to Import field) since portion_df and count_df rely on it
    • @@ -1317,9 +1335,9 @@ Using as.mo(..., allow_uncertain = 3)
    -
    +

    -Other

    +Other
    • More unit tests to ensure better integrity of functions
    @@ -1446,9 +1464,9 @@ Using as.mo(..., allow_uncertain = 3)Other small fixes
    -
    +

    -Other

    +Other
    • Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher
    -
    +

    -Other

    +Other
    • Expanded README.md with more examples
    • Added ORCID of authors to DESCRIPTION file
    • diff --git a/tests/appveyor/appveyor_tool.ps1 b/tests/appveyor/appveyor_tool.ps1 index 18f932f5..859b458f 100644 --- a/tests/appveyor/appveyor_tool.ps1 +++ b/tests/appveyor/appveyor_tool.ps1 @@ -126,7 +126,7 @@ Function InstallRtools { $rtoolsver = $env:RTOOLS_VERSION } - $rtoolsurl = $CRAN + "/bin/windows/Rtools/Rtools$rtoolsver.exe" + $rtoolsurl = $CRAN + "/bin/windows/Rtools/Rtools$rtoolsver-x86_64.exe" Progress ("Downloading Rtools from: " + $rtoolsurl) & "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../Rtools-current.exe -L $rtoolsurl