From 3d096d96c21a3b92d8a1ccc2c949436c173a42e9 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Mon, 26 Oct 2020 15:53:31 +0100 Subject: [PATCH] (v1.4.0.9009) bugfix for older R version --- .github/workflows/check.yaml | 14 ++++++----- DESCRIPTION | 2 +- NEWS.md | 2 +- R/aa_helper_functions.R | 6 ++++- R/mo.R | 12 ++++----- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 48 ++++++++++++++++++------------------ docs/pkgdown.yml | 2 +- docs/reference/index.html | 2 +- docs/survey.html | 2 +- 14 files changed, 53 insertions(+), 47 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index b328e2e0..549b23f8 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -41,8 +41,10 @@ name: R-code-check jobs: R-code-check: runs-on: ${{ matrix.config.os }} + + continue-on-error: ${{ matrix.config.allowfail }} - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + name: ${{ matrix.config.os }} (R-${{ matrix.config.r }}) strategy: fail-fast: false @@ -55,11 +57,11 @@ jobs: - {os: windows-latest, r: 'release'} - {os: windows-latest, r: 'oldrel'} - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - # - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - # - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.4', allowfail = true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.3', allowfail = true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true diff --git a/DESCRIPTION b/DESCRIPTION index 31916785..3695623f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.4.0.9008 +Version: 1.4.0.9009 Date: 2020-10-26 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 6470ba87..d09d3531 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.4.0.9008 +# AMR 1.4.0.9009 ## Last updated: 26 October 2020 ### New diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 20044608..a5a50604 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -271,8 +271,12 @@ import_fn <- function(name, pkg, error_on_fail = TRUE) { # - ignores formatted text while wrapping # - adds indentation dependent on the type of message (like NOTE) # - add additional formatting functions like blue or bold text -message_ <- function(..., appendLF = TRUE, add_fn = list(font_blue)) { +message_ <- function(..., appendLF = TRUE, add_fn = list(font_blue), as_note = TRUE) { msg <- paste0(c(...), collapse = "") + + if (isTRUE(as_note)) { + msg <- paste0("NOTE: ", gsub("note:? ?", "", msg, ignore.case = TRUE)) + } # we need to correct for already applied style, that adds text like "\033[31m\" msg_stripped <- font_stripstyle(msg) diff --git a/R/mo.R b/R/mo.R index daeb411e..d5ac604f 100755 --- a/R/mo.R +++ b/R/mo.R @@ -205,7 +205,6 @@ as.mo <- function(x, & all(x %in% reference_df[, 1][[1]])) { # has valid own reference_df - # (data.table not faster here) reference_df <- reference_df %pm>% pm_filter(!is.na(mo)) # keep only first two columns, second must be mo if (colnames(reference_df)[1] == "mo") { @@ -213,6 +212,9 @@ as.mo <- function(x, } else { reference_df <- reference_df[, c(1, 2)] } + # some microbial codes might be old + reference_df[, 1] <- as.mo(reference_df[, 1, drop = TRUE]) + colnames(reference_df)[1] <- "x" # remove factors, just keep characters suppressWarnings( @@ -221,9 +223,7 @@ as.mo <- function(x, suppressWarnings( y <- data.frame(x = x, stringsAsFactors = FALSE) %pm>% pm_left_join(reference_df, by = "x") %pm>% - pm_pull("mo") %pm>% - # run as.mo() for when using old microbial codes - as.mo() + pm_pull("mo") ) } else if (all(x[!is.na(x)] %in% MO_lookup$mo) @@ -415,7 +415,7 @@ exec_as.mo <- function(x, reference_df <- reference_df[, c(1, 2)] } # some microbial codes might be old - reference_df$mo <- as.mo(reference_df$mo) + reference_df[, 1] <- as.mo(reference_df[, 1, drop = TRUE]) colnames(reference_df)[1] <- "x" # remove factors, just keep characters @@ -1438,7 +1438,7 @@ exec_as.mo <- function(x, } msg <- paste0("Translation to ", nr2char(length(uncertainties$input)), " microorganism", plural[1], " ", plural[3], " guessed with uncertainty. Use mo_uncertainties() to review ", plural[2], ".") - message(font_red(msg)) + message_(msg) } # Becker ---- diff --git a/docs/404.html b/docs/404.html index 2b059ce4..9e1ff30d 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9008 + 1.4.0.9009 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index a59446e2..14d007cf 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9008 + 1.4.0.9009 diff --git a/docs/articles/index.html b/docs/articles/index.html index 5993fb35..a4270f1d 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9008 + 1.4.0.9009 diff --git a/docs/authors.html b/docs/authors.html index cddf97b3..1d9c6968 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9008 + 1.4.0.9009 diff --git a/docs/index.html b/docs/index.html index efafa8fa..22e94553 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.4.0.9008 + 1.4.0.9009 diff --git a/docs/news/index.html b/docs/news/index.html index 47933806..7472d540 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9008 + 1.4.0.9009 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

-AMR 1.4.0.9008 Unreleased +
+

+AMR 1.4.0.9009 Unreleased

@@ -470,7 +470,7 @@

Making this package independent of especially the tidyverse (e.g. packages dplyr and tidyr) tremendously increases sustainability on the long term, since tidyverse functions change quite often. Good for users, but hard for package maintainers. 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. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.

Negative effects of this change are:

    -
  • Function freq() that was borrowed from the cleaner package was removed. Use cleaner::freq(), or run library("cleaner") before you use freq().
  • +
  • Function freq() that was borrowed from the cleaner package was removed. Use cleaner::freq(), or run library("cleaner") before you use freq().
  • Printing values of class mo or rsi in a tibble will no longer be in colour and printing rsi in a tibble will show the class <ord>, not <rsi> anymore. This is purely a visual effect.
  • All functions from the mo_* family (like mo_name() and mo_gramstain()) are noticeably slower when running on hundreds of thousands of rows.
  • For developers: classes mo and ab now both also inherit class character, to support any data transformation. This change invalidates code that checks for class length == 1.
  • @@ -798,7 +798,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ #> invalid microorganism code, NA generated

This is important, because a value like "testvalue" could never be understood by e.g. mo_name(), although the class would suggest a valid microbial code.

-
  • Function freq() has moved to a new package, clean (CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq() function still works, since it is re-exported from the clean package (which will be installed automatically upon updating this AMR package).

  • +
  • Function freq() has moved to a new package, clean (CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq() function still works, since it is re-exported from the clean package (which will be installed automatically upon updating this AMR package).

  • Renamed data set septic_patients to example_isolates

  • @@ -1061,7 +1061,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • The age() function gained a new parameter exact to determine ages with decimals
  • Removed deprecated functions guess_mo(), guess_atc(), EUCAST_rules(), interpretive_reading(), rsi()
  • -
  • Frequency tables (freq()): +
  • Frequency tables (freq()):
    • speed improvement for microbial IDs

    • fixed factor level names for R Markdown

    • @@ -1070,12 +1070,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/

      support for boxplots:

       septic_patients %>% 
      -  freq(age) %>% 
      +  freq(age) %>% 
         boxplot()
       # grouped boxplots:
       septic_patients %>% 
         group_by(hospital_id) %>% 
      -  freq(age) %>%
      +  freq(age) %>%
         boxplot()
    @@ -1085,7 +1085,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Added ceftazidim intrinsic resistance to Streptococci
  • Changed default settings for age_groups(), to let groups of fives and tens end with 100+ instead of 120+
  • -
  • Fix for freq() for when all values are NA +
  • Fix for freq() for when all values are NA
  • Fix for first_isolate() for when dates are missing
  • Improved speed of guess_ab_col() @@ -1317,7 +1317,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • -
  • Frequency tables (freq() function): +
  • Frequency tables (freq() function):
    • Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:

      @@ -1326,15 +1326,15 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ # OLD WAY septic_patients %>% mutate(genus = mo_genus(mo)) %>% - freq(genus) + freq(genus) # NEW WAY septic_patients %>% - freq(mo_genus(mo)) + freq(mo_genus(mo)) # Even supports grouping variables: septic_patients %>% group_by(gender) %>% - freq(mo_genus(mo))
  • + freq(mo_genus(mo))
  • Header info is now available as a list, with the header function

  • The parameter header is now set to TRUE at default, even for markdown

  • @@ -1416,23 +1416,23 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Using portion_* functions now throws a warning when total available isolate is below parameter minimum

  • Functions as.mo, as.rsi, as.mic, as.atc and freq will not set package name as attribute anymore

  • -

    Frequency tables - freq():

    +

    Frequency tables - freq():

    @@ -1687,13 +1687,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/