# Class 'rsi' — as.rsi • AMR (for R)
This transforms a vector 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`

This transforms a vector 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)

    is.rsi(x)

    is.rsi.eligible(x)

## Arguments

x | vector

## Value

Ordered factor with new class `rsi`

## Details

The function `is.rsi.eligible` returns `TRUE` when a columns contains only valid antimicrobial interpretations (S and/or I and/or R), and `FALSE` otherwise.

## 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

    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(peni:rifa), 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)
    # }