1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 03:22:00 +02:00

(v1.5.0.9032) All group generics for MICs

This commit is contained in:
2021-03-07 13:52:39 +01:00
parent 91dd755cac
commit 850c123de7
40 changed files with 641 additions and 203 deletions

View File

@ -26,7 +26,7 @@
#' Random MIC Values/Disk Zones/RSI Generation
#'
#' These functions can be used for generating random MIC values and disk diffusion diameters, for AMR data analysis practice. By providing a microorganism and antimicrobial agent, the generated results will reflect reality as much as possible.
#' @inheritSection lifecycle Maturing Lifecycle
#' @inheritSection lifecycle Stable Lifecycle
#' @param size desired size of the returned vector
#' @param mo any character that can be coerced to a valid microorganism code with [as.mo()]
#' @param ab any character that can be coerced to a valid antimicrobial agent code with [as.ab()]
@ -119,7 +119,15 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) {
valid_mics <- suppressWarnings(as.mic(set_range_max / (2 ^ c(-3:3))))
set_range <- valid_mics[!is.na(valid_mics)]
}
return(as.mic(sample(set_range, size = size, replace = TRUE)))
out <- as.mic(sample(set_range, size = size, replace = TRUE))
# 50% chance that lowest will get <= and highest will get >=
if (runif(1) > 0.5) {
out[out == min(out)] <- paste0("<=", out[out == min(out)])
}
if (runif(1) > 0.5) {
out[out == max(out)] <- paste0(">=", out[out == max(out)])
}
return(out)
} else if (type == "DISK") {
set_range <- seq(from = as.integer(min(df$breakpoint_R) / 1.25),
to = as.integer(max(df$breakpoint_S) * 1.25),