diff --git a/DESCRIPTION b/DESCRIPTION index 7116d453..e290c931 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.4.0.9044 -Date: 2020-12-24 +Version: 1.4.0.9045 +Date: 2020-12-25 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 673ccb69..37c70f45 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.4.0.9044 -## Last updated: 24 December 2020 +# AMR 1.4.0.9045 +## Last updated: 25 December 2020 ### New * Function `is_new_episode()` to determine patient episodes which are not necessarily based on microorganisms. It also supports grouped variables with e.g. `mutate()`, `filter()` and `summarise()` of the `dplyr` package: diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 77b48c1d..b0536c0f 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -296,7 +296,6 @@ word_wrap <- function(..., indentation <- 0 + extra_indent } msg <- gsub("\n", paste0("\n", strrep(" ", indentation)), msg, fixed = TRUE) - # msg <- gsub("*|*", paste0("*|*", strrep(" ", indentation)), msg, fixed = TRUE) # remove trailing empty characters msg <- gsub("(\n| )+$", "", msg) @@ -538,7 +537,7 @@ get_current_data <- function(arg_name, call) { } get_root_env_address <- function() { - sub('', '\\1', utils::capture.output(sys.frames()[[1]])) + sub("", "\\1", utils::capture.output(sys.frames()[[1]])) } remember_thrown_message <- function(fn) { diff --git a/R/rsi_calc.R b/R/rsi_calc.R index 3294ac93..f852ebf3 100755 --- a/R/rsi_calc.R +++ b/R/rsi_calc.R @@ -147,10 +147,12 @@ rsi_calc <- function(..., } if (print_warning == TRUE) { - if (message_not_thrown_before("rsi_calc")) { - warning_("Increase speed by transforming to class on beforehand: your_data %pm>% mutate_if(is.rsi.eligible, as.rsi)", + # since rsi_calc() is always called from a count() or proportion() function, we use -1: + cll <- gsub("[^a-zA-Z0-9_]+", "_", paste(deparse(sys.calls()[[length(sys.calls()) - 1]]), collapse = "")) + if (message_not_thrown_before(cll)) { + warning_("Increase speed by transforming to class on beforehand: your_data %>% mutate_if(is.rsi.eligible, as.rsi)", call = FALSE) - remember_thrown_message("rsi_calc") + remember_thrown_message(cll) } } diff --git a/docs/404.html b/docs/404.html index d8222254..27e08d40 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9044 + 1.4.0.9045 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 5f62f2ae..ae5834e9 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9044 + 1.4.0.9045 diff --git a/docs/articles/index.html b/docs/articles/index.html index b5e7b58c..d9882af7 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9044 + 1.4.0.9045 diff --git a/docs/authors.html b/docs/authors.html index 65f35e46..d3d4c60a 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9044 + 1.4.0.9045 diff --git a/docs/index.html b/docs/index.html index 5f2e0ac9..f96c6373 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.4.0.9044 + 1.4.0.9045 diff --git a/docs/news/index.html b/docs/news/index.html index 134fa832..a26361bd 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9044 + 1.4.0.9045 @@ -236,13 +236,13 @@ Source: NEWS.md -
-

-AMR 1.4.0.9044 Unreleased +
+

+AMR 1.4.0.9045 Unreleased

-
+

-Last updated: 24 December 2020 +Last updated: 25 December 2020

@@ -519,7 +519,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.
  • @@ -856,7 +856,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

  • @@ -1125,7 +1125,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • The age() function gained a new argument 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

    • @@ -1135,12 +1135,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
       
       septic_patients %>% 
      -  freq(age) %>% 
      +  freq(age) %>% 
         boxplot()
       # grouped boxplots:
       septic_patients %>% 
         group_by(hospital_id) %>% 
      -  freq(age) %>%
      +  freq(age) %>%
         boxplot()
    @@ -1150,7 +1150,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() @@ -1391,7 +1391,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:

      @@ -1401,15 +1401,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 argument header is now set to TRUE at default, even for markdown

  • @@ -1492,7 +1492,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Using portion_* functions now throws a warning when total available isolate is below argument 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():

    • Support for grouping variables, test with:

      @@ -1500,14 +1500,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ septic_patients %>% group_by(hospital_id) %>% - freq(gender)
  • + freq(gender)
  • Support for (un)selecting columns:

     
     septic_patients %>% 
    -  freq(hospital_id) %>% 
    +  freq(hospital_id) %>% 
       select(-count, -cum_count) # only get item, percent, cum_percent
  • Check for hms::is.hms

  • @@ -1525,7 +1525,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Removed diacritics from all authors (columns microorganisms$ref and microorganisms.old$ref) to comply with CRAN policy to only allow ASCII characters

  • Fix for mo_property not working properly

  • Fix for eucast_rules where some Streptococci would become ceftazidime R in EUCAST rule 4.5

  • -
  • Support for named vectors of class mo, useful for top_freq()

  • +
  • Support for named vectors of class mo, useful for top_freq()

  • ggplot_rsi and scale_y_percent have breaks argument

  • AI improvements for as.mo:

    @@ -1693,13 +1693,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
     
     my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2))
    -freq(my_matrix)
    +freq(my_matrix)

    For lists, subsetting is possible:

     
     my_list = list(age = septic_patients$age, gender = septic_patients$gender)
    -my_list %>% freq(age)
    -my_list %>% freq(gender)
    +my_list %>% freq(age) +my_list %>% freq(gender)
  • @@ -1773,13 +1773,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    • A vignette to explain its usage
    • Support for rsi (antimicrobial resistance) to use as input
    • -
    • Support for table to use as input: freq(table(x, y)) +
    • Support for table to use as input: freq(table(x, y))
    • Support for existing functions hist and plot to use a frequency table as input: hist(freq(df$age))
    • Support for as.vector, as.data.frame, as_tibble and format
    • -
    • Support for quasiquotation: freq(mydata, mycolumn) is the same as mydata %>% freq(mycolumn) +
    • Support for quasiquotation: freq(mydata, mycolumn) is the same as mydata %>% freq(mycolumn)
    • Function top_freq function to return the top/below n items as vector
    • Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)
    • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 650c020a..7281d89d 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: 2020-12-24T22:24Z +last_built: 2020-12-24T23:05Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/index.html b/docs/reference/index.html index c78b4139..dba1ca14 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9044 + 1.4.0.9045 diff --git a/docs/survey.html b/docs/survey.html index 593f103d..daddda6c 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9044 + 1.4.0.9045 diff --git a/tests/testthat/test-first_isolate.R b/tests/testthat/test-first_isolate.R index ae4bd8e6..8f4267e0 100755 --- a/tests/testthat/test-first_isolate.R +++ b/tests/testthat/test-first_isolate.R @@ -152,12 +152,6 @@ test_that("first isolates work", { require("dplyr") - # look for columns itself - expect_message(first_isolate(example_isolates)) - expect_message(first_isolate(example_isolates %>% - mutate(mo = as.character(mo)) %>% - left_join_microorganisms())) - # if mo is not an mo class, result should be the same expect_identical(example_isolates %>% mutate(mo = as.character(mo)) %>% diff --git a/tests/testthat/test-proportion.R b/tests/testthat/test-proportion.R index b1589634..203e2342 100755 --- a/tests/testthat/test-proportion.R +++ b/tests/testthat/test-proportion.R @@ -52,6 +52,7 @@ test_that("proportions works", { 0.9382647, tolerance = 0.0001) + library(dplyr) # percentages expect_equal(example_isolates %>% group_by(hospital_id) %>% @@ -79,7 +80,7 @@ test_that("proportions works", { expect_warning(proportion_R(as.character(example_isolates$AMC))) expect_warning(proportion_S(as.character(example_isolates$AMC))) expect_warning(proportion_S(as.character(example_isolates$AMC, - example_isolates$GEN))) + example_isolates$GEN))) expect_warning(n_rsi(as.character(example_isolates$AMC, example_isolates$GEN))) expect_equal(suppressWarnings(n_rsi(as.character(example_isolates$AMC,