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 drug, the generated results will reflect reality as much as possible.
Usage
random_mic(size = NULL, mo = NULL, ab = NULL, ...)
random_disk(size = NULL, mo = NULL, ab = NULL, ...)
random_sir(size = NULL, prob_SIR = c(0.33, 0.33, 0.33), ...)
Arguments
- size
Desired size of the returned vector. If used in a data.frame call or
dplyr
verb, will get the current (group) size if left blank.- mo
Any character that can be coerced to a valid microorganism code with
as.mo()
.- ab
Any character that can be coerced to a valid antimicrobial drug code with
as.ab()
.- ...
Ignored, only in place to allow future extensions.
- prob_SIR
A vector of length 3: the probabilities for "S" (1st value), "I" (2nd value) and "R" (3rd value).
Details
The base R function sample()
is used for generating values.
Generated values are based on the EUCAST 2025 guideline as implemented in the clinical_breakpoints data set. To create specific generated values per bug or drug, set the mo
and/or ab
argument.
Examples
random_mic(25)
#> Class 'mic'
#> [1] <=0.001 8 0.002 256 256 256 0.125 0.25 0.005
#> [10] 1 0.01 32 32 256 0.01 32 8 0.025
#> [19] 0.0625 0.5 0.0625 0.5 0.01 0.125 0.5
random_disk(25)
#> Class 'disk'
#> [1] 48 46 26 46 17 46 15 50 20 13 48 44 6 47 26 15 12 20 11 45 8 41 45 14 37
random_sir(25)
#> Class 'sir'
#> [1] I R S R I S S I S R S R I R S S S S I R S S S S R
# \donttest{
# make the random generation more realistic by setting a bug and/or drug:
random_mic(25, "Klebsiella pneumoniae") # range 0.0625-64
#> Class 'mic'
#> [1] 2 0.25 0.002 0.025 0.01 0.0625 0.25 0.01 0.0625
#> [10] <=0.001 0.01 0.125 8 0.002 0.0625 0.002 >=256 >=256
#> [19] 0.5 >=256 1 0.125 64 64 0.25
random_mic(25, "Klebsiella pneumoniae", "meropenem") # range 0.0625-16
#> Class 'mic'
#> [1] 2 <=0.5 8 8 <=0.5 2 2 8 2 8 8 4
#> [13] 1 <=0.5 >=16 1 4 2 1 <=0.5 >=16 4 4 4
#> [25] 8
random_mic(25, "Streptococcus pneumoniae", "meropenem") # range 0.0625-4
#> Class 'mic'
#> [1] 8 0.5 2 0.125 <=0.025 0.25 0.0625 2 16
#> [10] 0.25 0.5 16 0.5 1 8 <=0.025 2 <=0.025
#> [19] 0.125 8 1 0.0625 2 1 4
random_disk(25, "Klebsiella pneumoniae") # range 8-50
#> Class 'disk'
#> [1] 39 19 39 20 37 11 18 10 46 46 9 40 46 24 30 31 13 12 42 50 43 12 34 22 47
random_disk(25, "Klebsiella pneumoniae", "ampicillin") # range 11-17
#> Class 'disk'
#> [1] 13 11 17 12 11 16 13 14 15 13 17 15 11 13 16 15 14 13 12 16 14 11 12 14 17
random_disk(25, "Streptococcus pneumoniae", "ampicillin") # range 12-27
#> Class 'disk'
#> [1] 24 19 20 27 27 20 21 16 23 20 22 17 27 20 23 22 22 16 16 24 24 19 25 17 19
# }