From 3829311dd3baffabc194aec16f8cfd2b723e3d2c Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Sat, 8 Jul 2023 21:00:49 +0200 Subject: [PATCH] random() fix --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/random.R | 15 ++++++++------- _pkgdown.yml | 1 + 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0ebfc264..de5ce2da 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.0.0.9027 +Version: 2.0.0.9028 Date: 2023-07-08 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 90f5f997..0757cc22 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.0.0.9027 +# AMR 2.0.0.9028 ## New * Clinical breakpoints and intrinsic resistance of EUCAST 2023 and CLSI 2023 have been added for `as.sir()`. EUCAST 2023 (v13.0) is now the new default guideline for all MIC and disks diffusion interpretations diff --git a/R/random.R b/R/random.R index 31f0f245..c9d14a89 100755 --- a/R/random.R +++ b/R/random.R @@ -94,13 +94,14 @@ random_sir <- function(size = NULL, prob_SIR = c(0.33, 0.33, 0.33), ...) { sample(as.sir(c("S", "I", "R")), size = size, replace = TRUE, prob = prob_SIR) } -random_exec <- function(type, size, mo = NULL, ab = NULL) { +random_exec <- function(method_type, size, mo = NULL, ab = NULL) { df <- AMR::clinical_breakpoints %pm>% pm_filter(guideline %like% "EUCAST") %pm>% pm_arrange(pm_desc(guideline)) %pm>% subset(guideline == max(guideline) & - method == type) - + method == method_type & + type == "human") + if (!is.null(mo)) { mo_coerced <- as.mo(mo) mo_include <- c( @@ -114,7 +115,7 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) { if (nrow(df_new) > 0) { df <- df_new } else { - warning_("in `random_", tolower(type), "()`: no rows found that match mo '", mo, "', ignoring argument `mo`") + warning_("in `random_", tolower(method_type), "()`: no rows found that match mo '", mo, "', ignoring argument `mo`") } } @@ -125,11 +126,11 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) { if (nrow(df_new) > 0) { df <- df_new } else { - warning_("in `random_", tolower(type), "()`: no rows found that match ab '", ab, "', ignoring argument `ab`") + warning_("in `random_", tolower(method_type), "()`: no rows found that match ab '", ab, "' (", ab_name(ab_coerced, tolower = TRUE, language = NULL), "), ignoring argument `ab`") } } - if (type == "MIC") { + if (method_type == "MIC") { # set range mic_range <- c(0.001, 0.002, 0.005, 0.010, 0.025, 0.0625, 0.125, 0.250, 0.5, 1, 2, 4, 8, 16, 32, 64, 128, 256) @@ -156,7 +157,7 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) { out[out == max(out)] <- paste0(">=", out[out == max(out)]) } return(out) - } else if (type == "DISK") { + } else if (method_type == "DISK") { set_range <- seq( from = as.integer(min(df$breakpoint_R, na.rm = TRUE) / 1.25), to = as.integer(max(df$breakpoint_S, na.rm = TRUE) * 1.25), diff --git a/_pkgdown.yml b/_pkgdown.yml index 685e23e6..e8f62468 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -233,6 +233,7 @@ reference: - "`example_isolates`" - "`microorganisms`" - "`microorganisms.codes`" + - "`microorganisms.groups`" - "`antibiotics`" - "`intrinsic_resistant`" - "`dosage`"