From 8fd8ee508f59acf0bc40e09aa2c611dd2fd24938 Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Fri, 13 Jun 2025 16:12:28 +0200 Subject: [PATCH] (v3.0.0.9004) random mic fix --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/random.R | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7ce982933..621ef0f22 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 3.0.0.9003 +Version: 3.0.0.9004 Date: 2025-06-13 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 1eff949ac..3b3c72638 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 3.0.0.9003 +# AMR 3.0.0.9004 ### New * Integration with the **tidymodels** framework to allow seamless use of MIC and SIR data in modelling pipelines via `recipes` diff --git a/R/random.R b/R/random.R index a5f003c2e..d5dd7b8b8 100755 --- a/R/random.R +++ b/R/random.R @@ -88,8 +88,9 @@ random_mic <- function(size = NULL, mo = NULL, ab = NULL, skew = "right", severi out[out == min(out)] <- paste0("<=", out[out == min(out)]) } if (stats::runif(1) > 0.5 && length(unique(out)) > 1) { - out[out == max(out)] <- paste0(">=", out[out == max(out)]) + out[out == max(out) & out %unlike% "<="] <- paste0(">=", out[out == max(out) & out %unlike% "<="]) } + return(out) } else { random_exec("MIC", size = size, mo = mo, ab = ab, skew = skew, severity = severity) @@ -163,7 +164,7 @@ random_exec <- function(method_type, size, mo = NULL, ab = NULL, skew = "right", out[out == min(out)] <- paste0("<=", out[out == min(out)]) } if (stats::runif(1) > 0.5 && length(unique(out)) > 1) { - out[out == max(out)] <- paste0(">=", out[out == max(out)]) + out[out == max(out) & out %unlike% "<="] <- paste0(">=", out[out == max(out) & out %unlike% "<="]) } return(as.mic(out)) } else if (method_type == "DISK") {