# Class 'rsi' — as.rsi • AMR (for R)
Interpret MIC values according to EUCAST or CLSI, or clean up existing RSI values. This transforms the input to a new class rsi, which is an ordered factor with levels S &lt; I &lt; R. Invalid antimicrobial interpretations will be translated as NA with a warning.

# Class 'rsi'

`as.rsi.Rd`

Interpret MIC values according to EUCAST or CLSI, or clean up existing RSI values. This transforms the input to a new class `rsi`, which is an ordered factor with levels `S < I < R`. Invalid antimicrobial interpretations will be translated as `NA` with a warning.

    as.rsi(x, ...)

    # S3 method for mic
    as.rsi(x, mo, ab, guideline = "EUCAST", ...)

    # S3 method for disk
    as.rsi(x, mo, ab, guideline = "EUCAST", ...)

    # S3 method for data.frame
    as.rsi(x, col_mo = NULL, guideline = "EUCAST",
      ...)

    is.rsi(x)

    is.rsi.eligible(x, threshold = 0.05)

## Arguments

x | vector of values (for class `mic`: an MIC value in mg/L, for class `disk`: a disk diffusion radius in millimeters)
... | parameters passed on to methods
mo | a microorganism code, generated with `as.mo`
ab | an antibiotic code, generated with `as.ab`
guideline | defaults to the latest included EUCAST guideline, run `unique(AMR::rsi_translation$guideline)` for all options
col_mo | column name of the unique IDs of the microorganisms (see `mo`), defaults to the first column of class `mo`. Values will be coerced using `as.mo`.
threshold | maximum fraction of `x` that is allowed to fail transformation, see Examples

## Value

Ordered factor with new class `rsi`

## Details

Run `unique(AMR::rsi_translation$guideline)` for a list of all supported guidelines.

After using `as.rsi`, you can use `eucast_rules` to (1) apply inferred susceptibility and resistance based on results of other antibiotics and (2) apply intrinsic resistance based on taxonomic properties of a microorganism.

The function `is.rsi.eligible` returns `TRUE` when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and `FALSE` otherwise. The threshold of 5% can be set with the `threshold` parameter.

## Interpretation of S, I and R

In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".

- S - Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.

- I - Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.

- R - Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.

Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.

Source: http://www.eucast.org/newsiandr/.

This AMR package honours this new insight.

## Read more on our website!

On our website https://msberends.gitlab.io/AMR you can find a tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.

## See also

`as.mic`

## Examples

    # NOT RUN {
    rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
    rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370), "A", "B", "C"))
    is.rsi(rsi_data)

    # this can also coerce combined MIC/RSI values:
    as.rsi("<= 0.002; S") # will return S

    # interpret MIC values
    as.rsi(x = as.mic(2),
           mo = as.mo("S. pneumoniae"),
           ab = "AMX",
           guideline = "EUCAST")
    as.rsi(x = as.mic(4),
           mo = as.mo("S. pneumoniae"),
           ab = "AMX",
           guideline = "EUCAST")

    plot(rsi_data)    # for percentages
    barplot(rsi_data) # for frequencies
    freq(rsi_data)    # frequency table with informative header

    # using dplyr's mutate
    library(dplyr)
    septic_patients %>%
      mutate_at(vars(PEN:RIF), as.rsi)

    # fastest way to transform all columns with already valid AB results to class `rsi`:
    septic_patients %>%
      mutate_if(is.rsi.eligible,
                as.rsi)

    # default threshold of `is.rsi.eligible` is 5%.
    is.rsi.eligible(WHONET$`First name`) # fails, >80% is invalid
    is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds
    # }