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.

random_mic(size = NULL, mo = NULL, ab = NULL, ...)

random_disk(size = NULL, mo = NULL, ab = NULL, ...)

random_rsi(size = NULL, prob_RSI = c(0.33, 0.33, 0.33), ...)



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.


any character that can be coerced to a valid microorganism code with


any character that can be coerced to a valid antimicrobial agent code with as.ab()


ignored, only in place to allow future extensions


a vector of length 3: the probabilities for "R" (1st value), "S" (2nd value) and "I" (3rd value)


class <mic> for random_mic() (see as.mic()) and class <disk> for random_disk() (see as.disk())


The base R function sample() is used for generating values.

Generated values are based on the latest EUCAST guideline implemented in the rsi_translation data set. To create specific generated values per bug or drug, set the mo and/or ab argument.

Stable Lifecycle

The lifecycle of this function is stable. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.

If the unlying code needs breaking changes, they will occur gradually. For example, a argument will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.

Read more on Our Website!

On our website you can find a comprehensive tutorial about how to conduct AMR data analysis, the complete documentation of all functions and an example analysis using WHONET data.



# \donttest{
# make the random generation more realistic by setting a bug and/or drug:
random_mic(100, "Klebsiella pneumoniae")                 # range 0.0625-64
random_mic(100, "Klebsiella pneumoniae", "meropenem")    # range 0.0625-16
random_mic(100, "Streptococcus pneumoniae", "meropenem") # range 0.0625-4

random_disk(100, "Klebsiella pneumoniae")                  # range 8-50
random_disk(100, "Klebsiella pneumoniae", "ampicillin")    # range 11-17
random_disk(100, "Streptococcus pneumoniae", "ampicillin") # range 12-27
# }