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 @@
NEWS.md
-
AMR
1.6.0.9017AMR
1.6.0.9018