diff --git a/DESCRIPTION b/DESCRIPTION index ddde8d8e..af820370 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.6.0.9017 +Version: 1.6.0.9018 Date: 2021-05-04 Title: Antimicrobial Resistance Data Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 4b7df6e8..4c3780d4 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# `AMR` 1.6.0.9017 +# `AMR` 1.6.0.9018 ## Last updated: 4 May 2021 ### New diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 77a3b109..d7dc7ee8 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -841,6 +841,14 @@ message_not_thrown_before <- function(fn, entire_session = FALSE) { is.null(pkg_env[[paste0("thrown_msg.", fn)]]) || !identical(pkg_env[[paste0("thrown_msg.", fn)]], unique_call_id(entire_session)) } +reset_all_thrown_messages <- function() { + # for unit tests, where the environment and highest system call do not change + # can be found in tests/testthat/*.R + pkg_env_contents <- ls(envir = pkg_env) + rm(list = pkg_env_contents[pkg_env_contents %like% "^thrown_msg."], + envir = pkg_env) +} + has_colour <- function() { # this is a base R version of crayon::has_color, but disables colours on emacs diff --git a/R/rsi.R b/R/rsi.R index ab57ca14..e9887aff 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -259,12 +259,22 @@ as.rsi.default <- function(x, ...) { } if (inherits(x, c("integer", "numeric", "double")) && all(x %in% c(1:3, NA))) { - x <- as.character(x) # this is needed to prevent the vctrs pkg to throw an error - x[x == "1"] <- "S" - x[x == "2"] <- "I" - x[x == "3"] <- "R" + x.bak <- x + x <- as.character(x) # this is needed to prevent the vctrs pkg from throwing an error - } else if (!all(is.na(x)) && !identical(levels(x), c("S", "I", "R")) && !all(x %in% c("R", "S", "I", NA))) { + # support haven package for importing e.g., from SPSS - it adds the 'labels' attribute + lbls <- attributes(x)$labels + if (!is.null(lbls) && all(c("R", "S", "I") %in% names(lbls)) && all(c(1:3) %in% lbls)) { + x[x.bak == 1] <- names(lbls[lbls == 1]) + x[x.bak == 2] <- names(lbls[lbls == 2]) + x[x.bak == 3] <- names(lbls[lbls == 3]) + } else { + x[x.bak == 1] <- "S" + x[x.bak == 2] <- "I" + x[x.bak == 3] <- "R" + } + + } else if (!all(is.na(x)) && !identical(levels(x), c("R", "S", "I")) && !all(x %in% c("R", "S", "I", NA))) { if (all(x %unlike% "(R|S|I)", na.rm = TRUE)) { # check if they are actually MICs or disks diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 50240859..1d4b876f 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 447edc0b..63be1bb7 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9017 + 1.6.0.9018 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 7552855e..ea71ff3d 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9017 + 1.6.0.9018 diff --git a/docs/articles/index.html b/docs/articles/index.html index 7ad64a3d..8c3f48fe 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9017 + 1.6.0.9018 diff --git a/docs/authors.html b/docs/authors.html index cc9f0127..a8f1d456 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9017 + 1.6.0.9018 diff --git a/docs/index.html b/docs/index.html index 9ce7b250..81900c84 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 1.6.0.9017 + 1.6.0.9018 diff --git a/docs/news/index.html b/docs/news/index.html index 9cf6e3f3..fb159a3c 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9017 + 1.6.0.9018 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

- Unreleased AMR 1.6.0.9017

+
+

+ Unreleased AMR 1.6.0.9018

Last updated: 4 May 2021 diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index fd2ef16b..12f9ba3b 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-04T10:36Z +last_built: 2021-05-04T13:19Z 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 e8e9c938..87c26f5f 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9017 + 1.6.0.9018

diff --git a/docs/survey.html b/docs/survey.html index 4019fe95..91358f34 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9017 + 1.6.0.9018