# `example_isolates` is a data set available in the AMR package.
-# See ?example_isolates.
-example_isolates
-#> # A tibble: 2,000 × 46
-#> date patient age gender ward mo PEN OXA FLC AMX
-#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
-#> 1 2002-01-02 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
-#> 2 2002-01-03 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
-#> 3 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
-#> 4 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
-#> 5 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
-#> 6 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
-#> 7 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
-#> 8 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
-#> 9 2002-01-16 067927 45 F ICU B_STPHY_EPDR R NA R NA
-#> 10 2002-01-17 858515 79 F ICU B_STPHY_EPDR R NA S NA
-#> # ℹ 1,990 more rows
-#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
-#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
-#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
-#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
-#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
-#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
-
-
-# Examples sections below are split into 'base R', 'dplyr', and 'data.table':
-
-
-# base R ------------------------------------------------------------------
-
-# select columns 'IPM' (imipenem) and 'MEM' (meropenem)
-example_isolates[, carbapenems()]
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> # A tibble: 2,000 × 2
-#> IPM MEM
-#> <sir> <sir>
-#> 1 NA NA
-#> 2 NA NA
-#> 3 NA NA
-#> 4 NA NA
-#> 5 NA NA
-#> 6 NA NA
-#> 7 NA NA
-#> 8 NA NA
-#> 9 NA NA
-#> 10 NA NA
-#> # ℹ 1,990 more rows
-
-# select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'
-example_isolates[, c("mo", aminoglycosides())]
-#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
-#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
-#> # A tibble: 2,000 × 5
-#> mo GEN TOB AMK KAN
-#> <mo> <sir> <sir> <sir> <sir>
-#> 1 B_ESCHR_COLI NA NA NA NA
-#> 2 B_ESCHR_COLI NA NA NA NA
-#> 3 B_STPHY_EPDR NA NA NA NA
-#> 4 B_STPHY_EPDR NA NA NA NA
-#> 5 B_STPHY_EPDR NA NA NA NA
-#> 6 B_STPHY_EPDR NA NA NA NA
-#> 7 B_STPHY_AURS NA S NA NA
-#> 8 B_STPHY_AURS NA S NA NA
-#> 9 B_STPHY_EPDR NA NA NA NA
-#> 10 B_STPHY_EPDR NA NA NA NA
-#> # ℹ 1,990 more rows
-
-# select only antibiotic columns with DDDs for oral treatment
-example_isolates[, administrable_per_os()]
-#> ℹ For administrable_per_os() using columns 'OXA' (oxacillin), 'FLC'
-#> (flucloxacillin), 'AMX' (amoxicillin), 'AMC' (amoxicillin/clavulanic acid),
-#> 'AMP' (ampicillin), 'CXM' (cefuroxime), 'KAN' (kanamycin), 'TMP'
-#> (trimethoprim), 'NIT' (nitrofurantoin), 'FOS' (fosfomycin), 'LNZ'
-#> (linezolid), 'CIP' (ciprofloxacin), 'MFX' (moxifloxacin), 'VAN'
-#> (vancomycin), 'TCY' (tetracycline), 'DOX' (doxycycline), 'ERY'
-#> (erythromycin), 'CLI' (clindamycin), 'AZM' (azithromycin), 'MTR'
-#> (metronidazole), 'CHL' (chloramphenicol), 'COL' (colistin), and 'RIF'
-#> (rifampicin)
-#> # A tibble: 2,000 × 23
-#> OXA FLC AMX AMC AMP CXM KAN TMP NIT FOS LNZ CIP MFX
-#> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir>
-#> 1 NA NA NA I NA I NA R NA NA R NA NA
-#> 2 NA NA NA I NA I NA R NA NA R NA NA
-#> 3 NA R NA NA NA R NA S NA NA NA NA NA
-#> 4 NA R NA NA NA R NA S NA NA NA NA NA
-#> 5 NA R NA NA NA R NA R NA NA NA NA NA
-#> 6 NA R NA NA NA R NA R NA NA NA NA NA
-#> 7 NA S R S R S NA R NA NA NA NA NA
-#> 8 NA S R S R S NA R NA NA NA NA NA
-#> 9 NA R NA NA NA R NA S NA NA NA S NA
-#> 10 NA S NA NA NA S NA S NA NA NA S NA
-#> # ℹ 1,990 more rows
-#> # ℹ 10 more variables: VAN <sir>, TCY <sir>, DOX <sir>, ERY <sir>, CLI <sir>,
-#> # AZM <sir>, MTR <sir>, CHL <sir>, COL <sir>, RIF <sir>
-
-# filter using any() or all()
-example_isolates[any(carbapenems() == "R"), ]
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> # A tibble: 55 × 46
-#> date patient age gender ward mo PEN OXA FLC AMX
-#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
-#> 1 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA
-#> 2 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA
-#> 3 2004-11-03 D65308 80 F ICU B_STNTR_MLTP R NA NA R
-#> 4 2005-04-21 452212 82 F ICU B_ENTRC NA NA NA NA
-#> 5 2005-04-22 452212 82 F ICU B_ENTRC NA NA NA NA
-#> 6 2005-04-22 452212 82 F ICU B_ENTRC_FACM NA NA NA NA
-#> 7 2007-02-21 8BBC46 61 F Clinical B_ENTRC_FACM NA NA NA NA
-#> 8 2007-12-15 401043 72 M Clinical B_ENTRC_FACM NA NA NA NA
-#> 9 2008-01-22 1710B8 82 M Clinical B_PROTS_MRBL R NA NA NA
-#> 10 2008-01-22 1710B8 82 M Clinical B_PROTS_MRBL R NA NA NA
-#> # ℹ 45 more rows
-#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
-#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
-#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
-#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
-#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
-#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
-subset(example_isolates, any(carbapenems() == "R"))
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> # A tibble: 55 × 46
-#> date patient age gender ward mo PEN OXA FLC AMX
-#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
-#> 1 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA
-#> 2 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA
-#> 3 2004-11-03 D65308 80 F ICU B_STNTR_MLTP R NA NA R
-#> 4 2005-04-21 452212 82 F ICU B_ENTRC NA NA NA NA
-#> 5 2005-04-22 452212 82 F ICU B_ENTRC NA NA NA NA
-#> 6 2005-04-22 452212 82 F ICU B_ENTRC_FACM NA NA NA NA
-#> 7 2007-02-21 8BBC46 61 F Clinical B_ENTRC_FACM NA NA NA NA
-#> 8 2007-12-15 401043 72 M Clinical B_ENTRC_FACM NA NA NA NA
-#> 9 2008-01-22 1710B8 82 M Clinical B_PROTS_MRBL R NA NA NA
-#> 10 2008-01-22 1710B8 82 M Clinical B_PROTS_MRBL R NA NA NA
-#> # ℹ 45 more rows
-#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
-#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
-#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
-#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
-#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
-#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
-
-# filter on any or all results in the carbapenem columns (i.e., IPM, MEM):
-example_isolates[any(carbapenems()), ]
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> ℹ Filtering any of columns 'IPM' and 'MEM' to contain value "S", "I" or "R"
-#> # A tibble: 962 × 46
-#> date patient age gender ward mo PEN OXA FLC AMX
-#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
-#> 1 2002-01-19 738003 71 M Clinical B_ESCHR_COLI R NA NA NA
-#> 2 2002-01-19 738003 71 M Clinical B_ESCHR_COLI R NA NA NA
-#> 3 2002-01-22 F35553 50 M ICU B_PROTS_MRBL R NA NA NA
-#> 4 2002-01-22 F35553 50 M ICU B_PROTS_MRBL R NA NA NA
-#> 5 2002-02-05 067927 45 F ICU B_SERRT_MRCS R NA NA R
-#> 6 2002-02-05 067927 45 F ICU B_SERRT_MRCS R NA NA R
-#> 7 2002-02-05 067927 45 F ICU B_SERRT_MRCS R NA NA R
-#> 8 2002-02-27 066895 85 F Clinical B_KLBSL_PNMN R NA NA R
-#> 9 2002-02-27 066895 85 F Clinical B_KLBSL_PNMN R NA NA R
-#> 10 2002-03-08 4FC193 69 M Clinical B_ESCHR_COLI R NA NA R
-#> # ℹ 952 more rows
-#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
-#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
-#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
-#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
-#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
-#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
-example_isolates[all(carbapenems()), ]
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> ℹ Filtering all of columns 'IPM' and 'MEM' to contain value "S", "I" or "R"
-#> # A tibble: 756 × 46
-#> date patient age gender ward mo PEN OXA FLC AMX
-#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
-#> 1 2002-04-14 F30196 73 M Outpat… B_STRPT_GRPB S NA S S
-#> 2 2003-04-08 114570 74 M ICU B_STRPT_PYGN S NA S S
-#> 3 2003-04-08 114570 74 M ICU B_STRPT_GRPA S NA S S
-#> 4 2003-04-08 114570 74 M ICU B_STRPT_GRPA S NA S S
-#> 5 2003-08-14 F71508 0 F Clinic… B_STRPT_GRPB S NA S S
-#> 6 2003-10-16 650870 63 F ICU B_ESCHR_COLI R NA NA R
-#> 7 2003-10-20 F35553 52 M ICU B_ENTRBC_CLOC R NA NA R
-#> 8 2003-10-20 F35553 52 M ICU B_ENTRBC_CLOC R NA NA R
-#> 9 2003-11-04 2FC253 87 F ICU B_ESCHR_COLI R NA NA NA
-#> 10 2003-11-04 2FC253 87 F ICU B_ESCHR_COLI R NA NA NA
-#> # ℹ 746 more rows
-#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
-#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
-#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
-#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
-#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
-#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
-
-# filter with multiple antibiotic selectors using c()
-example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ]
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
-#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
-#> # A tibble: 26 × 46
-#> date patient age gender ward mo PEN OXA FLC AMX
-#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
-#> 1 2004-11-03 D65308 80 F ICU B_STNTR_MLTP R NA NA R
-#> 2 2005-04-22 452212 82 F ICU B_ENTRC_FACM NA NA NA NA
-#> 3 2007-02-21 8BBC46 61 F Clinical B_ENTRC_FACM NA NA NA NA
-#> 4 2007-12-15 401043 72 M Clinical B_ENTRC_FACM NA NA NA NA
-#> 5 2008-12-06 501361 43 F Clinical B_STNTR_MLTP R NA NA R
-#> 6 2011-05-09 207325 82 F ICU B_ENTRC_FACM NA NA NA NA
-#> 7 2012-03-12 582258 80 M ICU B_STPHY_CONS R R R R
-#> 8 2012-05-19 C25552 89 F Outpati… B_STPHY_CONS R R R R
-#> 9 2012-07-17 F05015 83 M ICU B_STPHY_CONS R R R R
-#> 10 2012-07-20 404299 66 F Clinical B_STPHY_CONS R R R R
-#> # ℹ 16 more rows
-#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
-#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
-#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
-#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
-#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
-#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
-
-# filter + select in one go: get penicillins in carbapenem-resistant strains
-example_isolates[any(carbapenems() == "R"), penicillins()]
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> ℹ For penicillins() using columns 'PEN' (benzylpenicillin), 'OXA'
-#> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'
-#> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), and 'TZP'
-#> (piperacillin/tazobactam)
-#> # A tibble: 55 × 7
-#> PEN OXA FLC AMX AMC AMP TZP
-#> <sir> <sir> <sir> <sir> <sir> <sir> <sir>
-#> 1 NA NA NA NA NA NA NA
-#> 2 NA NA NA NA NA NA NA
-#> 3 R NA NA R R R R
-#> 4 NA NA NA NA NA NA R
-#> 5 NA NA NA NA NA NA R
-#> 6 NA NA NA NA NA NA R
-#> 7 NA NA NA NA NA NA R
-#> 8 NA NA NA NA NA NA R
-#> 9 R NA NA NA S NA S
-#> 10 R NA NA NA S NA S
-#> # ℹ 45 more rows
-
-# You can combine selectors with '&' to be more specific. For example,
-# penicillins() would select benzylpenicillin ('peni G') and
-# administrable_per_os() would select erythromycin. Yet, when combined these
-# drugs are both omitted since benzylpenicillin is not administrable per os
-# and erythromycin is not a penicillin:
-example_isolates[, penicillins() & administrable_per_os()]
-#> ℹ For penicillins() using columns 'PEN' (benzylpenicillin), 'OXA'
-#> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'
-#> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), and 'TZP'
-#> (piperacillin/tazobactam)
-#> ℹ For administrable_per_os() using columns 'OXA' (oxacillin), 'FLC'
-#> (flucloxacillin), 'AMX' (amoxicillin), 'AMC' (amoxicillin/clavulanic acid),
-#> 'AMP' (ampicillin), 'CXM' (cefuroxime), 'KAN' (kanamycin), 'TMP'
-#> (trimethoprim), 'NIT' (nitrofurantoin), 'FOS' (fosfomycin), 'LNZ'
-#> (linezolid), 'CIP' (ciprofloxacin), 'MFX' (moxifloxacin), 'VAN'
-#> (vancomycin), 'TCY' (tetracycline), 'DOX' (doxycycline), 'ERY'
-#> (erythromycin), 'CLI' (clindamycin), 'AZM' (azithromycin), 'MTR'
-#> (metronidazole), 'CHL' (chloramphenicol), 'COL' (colistin), and 'RIF'
-#> (rifampicin)
-#> # A tibble: 2,000 × 5
-#> OXA FLC AMX AMC AMP
-#> <sir> <sir> <sir> <sir> <sir>
-#> 1 NA NA NA I NA
-#> 2 NA NA NA I NA
-#> 3 NA R NA NA NA
-#> 4 NA R NA NA NA
-#> 5 NA R NA NA NA
-#> 6 NA R NA NA NA
-#> 7 NA S R S R
-#> 8 NA S R S R
-#> 9 NA R NA NA NA
-#> 10 NA S NA NA NA
-#> # ℹ 1,990 more rows
-
-# ab_selector() applies a filter in the `antibiotics` data set and is thus
-# very flexible. For instance, to select antibiotic columns with an oral DDD
-# of at least 1 gram:
-example_isolates[, ab_selector(oral_ddd > 1 & oral_units == "g")]
-#> ℹ For ab_selector(oral_ddd > 1 & oral_units == "g") using columns 'OXA'
-#> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'
-#> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), 'KAN' (kanamycin), 'FOS'
-#> (fosfomycin), 'LNZ' (linezolid), 'VAN' (vancomycin), 'ERY' (erythromycin),
-#> 'CLI' (clindamycin), 'MTR' (metronidazole), and 'CHL' (chloramphenicol)
-#> # A tibble: 2,000 × 13
-#> OXA FLC AMX AMC AMP KAN FOS LNZ VAN ERY CLI MTR CHL
-#> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir>
-#> 1 NA NA NA I NA NA NA R R R R NA NA
-#> 2 NA NA NA I NA NA NA R R R R NA NA
-#> 3 NA R NA NA NA NA NA NA S R NA NA NA
-#> 4 NA R NA NA NA NA NA NA S R NA NA NA
-#> 5 NA R NA NA NA NA NA NA S R NA NA NA
-#> 6 NA R NA NA NA NA NA NA S R R NA NA
-#> 7 NA S R S R NA NA NA S S NA NA NA
-#> 8 NA S R S R NA NA NA S S NA NA NA
-#> 9 NA R NA NA NA NA NA NA S R NA NA NA
-#> 10 NA S NA NA NA NA NA NA S S NA NA NA
-#> # ℹ 1,990 more rows
-
-# \donttest{
-# dplyr -------------------------------------------------------------------
-
-if (require("dplyr")) {
- tibble(kefzol = random_sir(5)) %>%
- select(cephalosporins())
-}
-#> ℹ For cephalosporins() using column 'kefzol' (cefazolin)
-#> # A tibble: 5 × 1
-#> kefzol
-#> <sir>
-#> 1 S
-#> 2 R
-#> 3 S
-#> 4 S
-#> 5 I
-
-if (require("dplyr")) {
- # get AMR for all aminoglycosides e.g., per ward:
- example_isolates %>%
- group_by(ward) %>%
- summarise(across(aminoglycosides(), resistance))
-}
-#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
-#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
-#> Warning: There was 1 warning in `summarise()`.
-#> ℹ In argument: `across(aminoglycosides(), resistance)`.
-#> ℹ In group 3: `ward = "Outpatient"`.
-#> Caused by warning:
-#> ! Introducing NA: only 23 results available for KAN in group: ward =
-#> "Outpatient" (minimum = 30).
-#> # A tibble: 3 × 5
-#> ward GEN TOB AMK KAN
-#> <chr> <dbl> <dbl> <dbl> <dbl>
-#> 1 Clinical 0.229 0.315 0.626 1
-#> 2 ICU 0.290 0.400 0.662 1
-#> 3 Outpatient 0.2 0.368 0.605 NA
-if (require("dplyr")) {
- # You can combine selectors with '&' to be more specific:
- example_isolates %>%
- select(penicillins() & administrable_per_os())
-}
-#> ℹ For penicillins() using columns 'PEN' (benzylpenicillin), 'OXA'
-#> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'
-#> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), and 'TZP'
-#> (piperacillin/tazobactam)
-#> ℹ For administrable_per_os() using columns 'OXA' (oxacillin), 'FLC'
-#> (flucloxacillin), 'AMX' (amoxicillin), 'AMC' (amoxicillin/clavulanic acid),
-#> 'AMP' (ampicillin), 'CXM' (cefuroxime), 'KAN' (kanamycin), 'TMP'
-#> (trimethoprim), 'NIT' (nitrofurantoin), 'FOS' (fosfomycin), 'LNZ'
-#> (linezolid), 'CIP' (ciprofloxacin), 'MFX' (moxifloxacin), 'VAN'
-#> (vancomycin), 'TCY' (tetracycline), 'DOX' (doxycycline), 'ERY'
-#> (erythromycin), 'CLI' (clindamycin), 'AZM' (azithromycin), 'MTR'
-#> (metronidazole), 'CHL' (chloramphenicol), 'COL' (colistin), and 'RIF'
-#> (rifampicin)
-#> # A tibble: 2,000 × 5
-#> OXA FLC AMX AMC AMP
-#> <sir> <sir> <sir> <sir> <sir>
-#> 1 NA NA NA I NA
-#> 2 NA NA NA I NA
-#> 3 NA R NA NA NA
-#> 4 NA R NA NA NA
-#> 5 NA R NA NA NA
-#> 6 NA R NA NA NA
-#> 7 NA S R S R
-#> 8 NA S R S R
-#> 9 NA R NA NA NA
-#> 10 NA S NA NA NA
-#> # ℹ 1,990 more rows
-if (require("dplyr")) {
- # get AMR for only drugs that matter - no intrinsic resistance:
- example_isolates %>%
- filter(mo_genus() %in% c("Escherichia", "Klebsiella")) %>%
- group_by(ward) %>%
- summarise(across(not_intrinsic_resistant(), resistance))
-}
-#> ℹ Using column 'mo' as input for mo_genus()
-#> ℹ For not_intrinsic_resistant() removing columns 'PEN'
-#> (benzylpenicillin), 'LNZ' (linezolid), 'VAN' (vancomycin), 'TEC'
-#> (teicoplanin), 'ERY' (erythromycin), 'CLI' (clindamycin), 'AZM'
-#> (azithromycin), and 'RIF' (rifampicin)
-#> Warning: There were 52 warnings in `summarise()`.
-#> The first warning was:
-#> ℹ In argument: `across(not_intrinsic_resistant(), resistance)`.
-#> ℹ In group 1: `ward = "Clinical"`.
-#> Caused by warning:
-#> ! Introducing NA: no results available for OXA in group: ward = "Clinical"
-#> (minimum = 30).
-#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 51 remaining warnings.
-#> # A tibble: 3 × 33
-#> ward OXA FLC AMX AMC AMP TZP CZO FEP CXM FOX
-#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
-#> 1 Clin… NA NA 0.606 0.121 0.606 0.0504 0.0656 0.0159 0.0622 0.0648
-#> 2 ICU NA NA 0.535 0.172 0.535 0.119 NA 0.0722 0.0828 0.0992
-#> 3 Outp… NA NA NA NA NA NA NA NA NA NA
-#> # ℹ 22 more variables: CTX <dbl>, CAZ <dbl>, CRO <dbl>, GEN <dbl>, TOB <dbl>,
-#> # AMK <dbl>, KAN <dbl>, TMP <dbl>, SXT <dbl>, NIT <dbl>, FOS <dbl>,
-#> # CIP <dbl>, MFX <dbl>, TCY <dbl>, TGC <dbl>, DOX <dbl>, IPM <dbl>,
-#> # MEM <dbl>, MTR <dbl>, CHL <dbl>, COL <dbl>, MUP <dbl>
-if (require("dplyr")) {
- # get susceptibility for antibiotics whose name contains "trim":
- example_isolates %>%
- filter(first_isolate()) %>%
- group_by(ward) %>%
- summarise(across(ab_selector(name %like% "trim"), susceptibility))
-}
-#> ℹ For ab_selector(name %like% "trim") using columns 'TMP' (trimethoprim)
-#> and 'SXT' (trimethoprim/sulfamethoxazole)
-#> # A tibble: 3 × 3
-#> ward TMP SXT
-#> <chr> <dbl> <dbl>
-#> 1 Clinical 0.627 0.807
-#> 2 ICU 0.551 0.780
-#> 3 Outpatient 0.667 0.821
-if (require("dplyr")) {
- # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
- example_isolates %>%
- select(carbapenems())
-}
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> # A tibble: 2,000 × 2
-#> IPM MEM
-#> <sir> <sir>
-#> 1 NA NA
-#> 2 NA NA
-#> 3 NA NA
-#> 4 NA NA
-#> 5 NA NA
-#> 6 NA NA
-#> 7 NA NA
-#> 8 NA NA
-#> 9 NA NA
-#> 10 NA NA
-#> # ℹ 1,990 more rows
-if (require("dplyr")) {
- # this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
- example_isolates %>%
- select(mo, aminoglycosides())
-}
-#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
-#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
-#> # A tibble: 2,000 × 5
-#> mo GEN TOB AMK KAN
-#> <mo> <sir> <sir> <sir> <sir>
-#> 1 B_ESCHR_COLI NA NA NA NA
-#> 2 B_ESCHR_COLI NA NA NA NA
-#> 3 B_STPHY_EPDR NA NA NA NA
-#> 4 B_STPHY_EPDR NA NA NA NA
-#> 5 B_STPHY_EPDR NA NA NA NA
-#> 6 B_STPHY_EPDR NA NA NA NA
-#> 7 B_STPHY_AURS NA S NA NA
-#> 8 B_STPHY_AURS NA S NA NA
-#> 9 B_STPHY_EPDR NA NA NA NA
-#> 10 B_STPHY_EPDR NA NA NA NA
-#> # ℹ 1,990 more rows
-if (require("dplyr")) {
- # any() and all() work in dplyr's filter() too:
- example_isolates %>%
- filter(
- any(aminoglycosides() == "R"),
- all(cephalosporins_2nd() == "R")
- )
-}
-#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
-#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
-#> ℹ For cephalosporins_2nd() using columns 'CXM' (cefuroxime) and 'FOX'
-#> (cefoxitin)
-#> # A tibble: 112 × 46
-#> date patient age gender ward mo PEN OXA FLC AMX
-#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
-#> 1 2002-02-21 4FC193 69 M Clinical B_ENTRC_FACM NA NA NA NA
-#> 2 2002-03-16 4FC193 69 M Clinical B_PSDMN_AERG R NA NA R
-#> 3 2002-04-08 130252 78 M ICU B_ENTRC_FCLS NA NA NA NA
-#> 4 2002-06-23 798871 82 M Clinical B_ENTRC_FCLS NA NA NA NA
-#> 5 2002-06-23 798871 82 M Clinical B_ENTRC_FCLS NA NA NA NA
-#> 6 2002-07-21 955940 82 F Clinical B_PSDMN_AERG R NA NA R
-#> 7 2002-07-21 955940 82 F Clinical B_PSDMN_AERG R NA NA R
-#> 8 2003-08-13 F35553 52 M ICU B_ENTRC_FCLS NA NA NA NA
-#> 9 2003-09-05 F35553 52 M ICU B_ENTRC_FCLS NA NA NA NA
-#> 10 2004-06-09 529296 69 M ICU B_ENTRC_FACM NA NA NA NA
-#> # ℹ 102 more rows
-#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
-#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
-#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
-#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
-#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
-#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
-if (require("dplyr")) {
- # also works with c():
- example_isolates %>%
- filter(any(c(carbapenems(), aminoglycosides()) == "R"))
-}
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
-#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
-#> # A tibble: 531 × 46
-#> date patient age gender ward mo PEN OXA FLC AMX
-#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
-#> 1 2002-02-21 4FC193 69 M Clinical B_ENTRC_FACM NA NA NA NA
-#> 2 2002-03-16 4FC193 69 M Clinical B_PSDMN_AERG R NA NA R
-#> 3 2002-03-17 B30560 78 M Clinical B_STPHY_CONS R NA R R
-#> 4 2002-04-04 E61143 67 M Clinical B_STRPT_SNGN S NA NA S
-#> 5 2002-04-08 130252 78 M ICU B_ENTRC_FCLS NA NA NA NA
-#> 6 2002-04-14 F30196 73 M Outpati… B_STRPT_GRPB S NA S S
-#> 7 2002-05-07 D91570 83 M Clinical B_STPHY_CONS R NA R R
-#> 8 2002-05-07 D91570 83 M Clinical B_STPHY_CONS R NA R R
-#> 9 2002-05-14 077552 86 F Clinical B_STRPT_PNMN S NA NA S
-#> 10 2002-05-14 077552 86 F Clinical B_STRPT_PNMN S NA NA S
-#> # ℹ 521 more rows
-#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
-#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
-#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
-#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
-#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
-#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
-if (require("dplyr")) {
- # not setting any/all will automatically apply all():
- example_isolates %>%
- filter(aminoglycosides() == "R")
-}
-#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
-#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
-#> ℹ Assuming a filter on all 4 aminoglycosides. Wrap around all() or
-#> any() to prevent this note.
-#> # A tibble: 427 × 46
-#> date patient age gender ward mo PEN OXA FLC AMX
-#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
-#> 1 2002-02-21 4FC193 69 M Clinical B_ENTRC_FACM NA NA NA NA
-#> 2 2002-03-17 B30560 78 M Clinical B_STPHY_CONS R NA R R
-#> 3 2002-04-04 E61143 67 M Clinical B_STRPT_SNGN S NA NA S
-#> 4 2002-04-08 130252 78 M ICU B_ENTRC_FCLS NA NA NA NA
-#> 5 2002-04-14 F30196 73 M Outpati… B_STRPT_GRPB S NA S S
-#> 6 2002-05-07 D91570 83 M Clinical B_STPHY_CONS R NA R R
-#> 7 2002-05-07 D91570 83 M Clinical B_STPHY_CONS R NA R R
-#> 8 2002-05-14 077552 86 F Clinical B_STRPT_PNMN S NA NA S
-#> 9 2002-05-14 077552 86 F Clinical B_STRPT_PNMN S NA NA S
-#> 10 2002-05-16 D25302 65 F ICU B_STRPT_ANGN S NA NA S
-#> # ℹ 417 more rows
-#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
-#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
-#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
-#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
-#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
-#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
-if (require("dplyr")) {
- # this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
- example_isolates %>%
- select(mo, ab_class("mycobact"))
-}
-#> ℹ For ab_class("mycobact") using column 'RIF' (rifampicin)
-#> # A tibble: 2,000 × 2
-#> mo RIF
-#> <mo> <sir>
-#> 1 B_ESCHR_COLI R
-#> 2 B_ESCHR_COLI R
-#> 3 B_STPHY_EPDR NA
-#> 4 B_STPHY_EPDR NA
-#> 5 B_STPHY_EPDR NA
-#> 6 B_STPHY_EPDR NA
-#> 7 B_STPHY_AURS NA
-#> 8 B_STPHY_AURS NA
-#> 9 B_STPHY_EPDR NA
-#> 10 B_STPHY_EPDR NA
-#> # ℹ 1,990 more rows
-if (require("dplyr")) {
- # get bug/drug combinations for only glycopeptides in Gram-positives:
- example_isolates %>%
- filter(mo_is_gram_positive()) %>%
- select(mo, glycopeptides()) %>%
- bug_drug_combinations() %>%
- format()
-}
-#> ℹ Using column 'mo' as input for mo_is_gram_positive()
-#> ℹ For glycopeptides() using columns 'VAN' (vancomycin) and 'TEC'
-#> (teicoplanin)
-#> # A tibble: 2 × 8
-#> Group Drug CoNS `E. faecalis` `S. aureus` `S. epidermidis` `S. hominis`
-#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
-#> 1 "Glycopep… Teic… "" "" " 0.0% (0/… "64.1% (25/39)" " 6.8% (4/5…
-#> 2 "" Vanc… " 0.… " 0.0% (0/39… " 0.0% (0/… " 0.0% (0/171)" " 0.0% (0/8…
-#> # ℹ 1 more variable: `S. pneumoniae` <chr>
-if (require("dplyr")) {
- data.frame(
- some_column = "some_value",
- J01CA01 = "S"
- ) %>% # ATC code of ampicillin
- select(penicillins()) # only the 'J01CA01' column will be selected
-}
-#> ℹ For penicillins() using column 'J01CA01' (ampicillin)
-#> J01CA01
-#> 1 S
-if (require("dplyr")) {
- # with recent versions of dplyr, this is all equal:
- x <- example_isolates[carbapenems() == "R", ]
- y <- example_isolates %>% filter(carbapenems() == "R")
- z <- example_isolates %>% filter(if_all(carbapenems(), ~ .x == "R"))
- identical(x, y) && identical(y, z)
-}
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> ℹ Assuming a filter on all 2 carbapenems. Wrap around all() or any() to
-#> prevent this note.
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> ℹ Assuming a filter on all 2 carbapenems. Wrap around all() or any() to
-#> prevent this note.
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> [1] TRUE
-
-
-# data.table --------------------------------------------------------------
-
-# data.table is supported as well, just use it in the same way as with
-# base R, but add `with = FALSE` if using a single AB selector.
-
-if (require("data.table")) {
- dt <- as.data.table(example_isolates)
-
- # this does not work, it returns column *names*
- dt[, carbapenems()]
-}
-#> Loading required package: data.table
-#>
-#> Attaching package: ‘data.table’
-#> The following objects are masked from ‘package:dplyr’:
-#>
-#> between, first, last
-#> The following objects are masked from ‘package:AMR’:
-#>
-#> %like%, like
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> [1] "IPM" "MEM"
-#> attr(,"class")
-#> [1] "ab_selector" "character"
-if (require("data.table")) {
- # so `with = FALSE` is required
- dt[, carbapenems(), with = FALSE]
-}
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> IPM MEM
-#> <sir> <sir>
-#> 1: <NA> <NA>
-#> 2: <NA> <NA>
-#> 3: <NA> <NA>
-#> 4: <NA> <NA>
-#> 5: <NA> <NA>
-#> ---
-#> 1996: <NA> <NA>
-#> 1997: S S
-#> 1998: S S
-#> 1999: S S
-#> 2000: S S
-
-# for multiple selections or AB selectors, `with = FALSE` is not needed:
-if (require("data.table")) {
- dt[, c("mo", aminoglycosides())]
-}
-#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
-#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
-#> mo GEN TOB AMK KAN
-#> <mo> <sir> <sir> <sir> <sir>
-#> 1: B_ESCHR_COLI <NA> <NA> <NA> <NA>
-#> 2: B_ESCHR_COLI <NA> <NA> <NA> <NA>
-#> 3: B_STPHY_EPDR <NA> <NA> <NA> <NA>
-#> 4: B_STPHY_EPDR <NA> <NA> <NA> <NA>
-#> 5: B_STPHY_EPDR <NA> <NA> <NA> <NA>
-#> ---
-#> 1996: B_STRPT_PNMN R R R R
-#> 1997: B_ESCHR_COLI S S S <NA>
-#> 1998: B_STPHY_CONS S <NA> <NA> <NA>
-#> 1999: B_ESCHR_COLI S S <NA> <NA>
-#> 2000: B_KLBSL_PNMN S S <NA> <NA>
-if (require("data.table")) {
- dt[, c(carbapenems(), aminoglycosides())]
-}
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
-#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
-#> IPM MEM GEN TOB AMK KAN
-#> <sir> <sir> <sir> <sir> <sir> <sir>
-#> 1: <NA> <NA> <NA> <NA> <NA> <NA>
-#> 2: <NA> <NA> <NA> <NA> <NA> <NA>
-#> 3: <NA> <NA> <NA> <NA> <NA> <NA>
-#> 4: <NA> <NA> <NA> <NA> <NA> <NA>
-#> 5: <NA> <NA> <NA> <NA> <NA> <NA>
-#> ---
-#> 1996: <NA> <NA> R R R R
-#> 1997: S S S S S <NA>
-#> 1998: S S S <NA> <NA> <NA>
-#> 1999: S S S S <NA> <NA>
-#> 2000: S S S S <NA> <NA>
-
-# row filters are also supported:
-if (require("data.table")) {
- dt[any(carbapenems() == "S"), ]
-}
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> date patient age gender ward mo PEN OXA FLC
-#> <Date> <char> <num> <char> <char> <mo> <sir> <sir> <sir>
-#> 1: 2002-01-19 738003 71 M Clinical B_ESCHR_COLI R <NA> <NA>
-#> 2: 2002-01-19 738003 71 M Clinical B_ESCHR_COLI R <NA> <NA>
-#> 3: 2002-01-22 F35553 50 M ICU B_PROTS_MRBL R <NA> <NA>
-#> 4: 2002-01-22 F35553 50 M ICU B_PROTS_MRBL R <NA> <NA>
-#> 5: 2002-02-05 067927 45 F ICU B_SERRT_MRCS R <NA> <NA>
-#> ---
-#> 905: 2005-04-12 D71461 70 M ICU B_ESCHR_COLI R <NA> <NA>
-#> 906: 2009-11-12 650870 69 F Outpatient B_ESCHR_COLI R <NA> <NA>
-#> 907: 2012-06-14 8CBCF2 41 F Clinical B_STPHY_CONS R S S
-#> 908: 2012-10-11 175532 78 M Clinical B_ESCHR_COLI R <NA> <NA>
-#> 909: 2013-11-23 A97263 77 M Clinical B_KLBSL_PNMN R <NA> <NA>
-#> AMX AMC AMP TZP CZO FEP CXM FOX CTX CAZ CRO GEN
-#> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir>
-#> 1: <NA> I <NA> <NA> <NA> <NA> S <NA> S <NA> S <NA>
-#> 2: <NA> I <NA> <NA> <NA> <NA> S <NA> S <NA> S <NA>
-#> 3: <NA> I <NA> <NA> <NA> <NA> S <NA> S S S <NA>
-#> 4: <NA> I <NA> <NA> <NA> <NA> S <NA> S S S <NA>
-#> 5: R R R <NA> R <NA> R R <NA> <NA> <NA> <NA>
-#> ---
-#> 905: S S S S <NA> S S S S S S S
-#> 906: S S S S S S S S S S S S
-#> 907: <NA> S <NA> <NA> S S S S S R S S
-#> 908: R S R S <NA> S R R S S S S
-#> 909: R S R S <NA> S S S S S S S
-#> TOB AMK KAN TMP SXT NIT FOS LNZ CIP MFX VAN TEC
-#> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir>
-#> 1: S <NA> <NA> S S <NA> <NA> R <NA> <NA> R R
-#> 2: S <NA> <NA> S S <NA> <NA> R <NA> <NA> R R
-#> 3: <NA> <NA> <NA> S S R <NA> R S <NA> R R
-#> 4: <NA> <NA> <NA> S S R <NA> R S <NA> R R
-#> 5: <NA> <NA> <NA> S S R <NA> R S <NA> R R
-#> ---
-#> 905: S S <NA> <NA> S S <NA> R S <NA> R R
-#> 906: S S <NA> S S S <NA> R S <NA> R R
-#> 907: <NA> <NA> <NA> S S <NA> <NA> <NA> S <NA> S <NA>
-#> 908: S <NA> <NA> R R R <NA> R R R R R
-#> 909: S <NA> <NA> S S S <NA> R S <NA> R R
-#> TCY TGC DOX ERY CLI AZM IPM MEM MTR CHL COL MUP
-#> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir> <sir>
-#> 1: <NA> <NA> <NA> R R R S <NA> <NA> <NA> <NA> <NA>
-#> 2: <NA> <NA> <NA> R R R S <NA> <NA> <NA> <NA> <NA>
-#> 3: R R R R R R S <NA> <NA> <NA> R <NA>
-#> 4: R R R R R R S <NA> <NA> <NA> R <NA>
-#> 5: R R R R R R S <NA> <NA> <NA> R <NA>
-#> ---
-#> 905: <NA> <NA> <NA> R R R S S <NA> <NA> <NA> <NA>
-#> 906: <NA> <NA> <NA> R R R S S <NA> <NA> <NA> <NA>
-#> 907: <NA> <NA> <NA> S S S S S <NA> <NA> R <NA>
-#> 908: <NA> <NA> <NA> R R R S S <NA> <NA> S <NA>
-#> 909: <NA> <NA> <NA> R R R S S <NA> <NA> S <NA>
-#> RIF
-#> <sir>
-#> 1: R
-#> 2: R
-#> 3: R
-#> 4: R
-#> 5: R
-#> ---
-#> 905: R
-#> 906: R
-#> 907: <NA>
-#> 908: R
-#> 909: R
-if (require("data.table")) {
- dt[any(carbapenems() == "S"), penicillins(), with = FALSE]
-}
-#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
-#> ℹ For penicillins() using columns 'PEN' (benzylpenicillin), 'OXA'
-#> (oxacillin), 'FLC' (flucloxacillin), 'AMX' (amoxicillin), 'AMC'
-#> (amoxicillin/clavulanic acid), 'AMP' (ampicillin), and 'TZP'
-#> (piperacillin/tazobactam)
-#> PEN OXA FLC AMX AMC AMP TZP
-#> <sir> <sir> <sir> <sir> <sir> <sir> <sir>
-#> 1: R <NA> <NA> <NA> I <NA> <NA>
-#> 2: R <NA> <NA> <NA> I <NA> <NA>
-#> 3: R <NA> <NA> <NA> I <NA> <NA>
-#> 4: R <NA> <NA> <NA> I <NA> <NA>
-#> 5: R <NA> <NA> R R R <NA>
-#> ---
-#> 905: R <NA> <NA> S S S S
-#> 906: R <NA> <NA> S S S S
-#> 907: R S S <NA> S <NA> <NA>
-#> 908: R <NA> <NA> R S R S
-#> 909: R <NA> <NA> R S R S
-# }
-