These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class or group, without the need to define the columns or antibiotic abbreviations. In short, if you have a column name that resembles an antimicrobial agent, it will be picked up by any of these functions that matches its pharmaceutical class: "cefazolin", "CZO" and "J01DB04" will all be picked up by cephalosporins()
.
Usage
ab_class(ab_class, only_rsi_columns = FALSE, only_treatable = TRUE, ...)
ab_selector(filter, only_rsi_columns = FALSE, only_treatable = TRUE, ...)
aminoglycosides(only_rsi_columns = FALSE, only_treatable = TRUE, ...)
aminopenicillins(only_rsi_columns = FALSE, ...)
antifungals(only_rsi_columns = FALSE, ...)
antimycobacterials(only_rsi_columns = FALSE, ...)
betalactams(only_rsi_columns = FALSE, only_treatable = TRUE, ...)
carbapenems(only_rsi_columns = FALSE, only_treatable = TRUE, ...)
cephalosporins(only_rsi_columns = FALSE, ...)
cephalosporins_1st(only_rsi_columns = FALSE, ...)
cephalosporins_2nd(only_rsi_columns = FALSE, ...)
cephalosporins_3rd(only_rsi_columns = FALSE, ...)
cephalosporins_4th(only_rsi_columns = FALSE, ...)
cephalosporins_5th(only_rsi_columns = FALSE, ...)
fluoroquinolones(only_rsi_columns = FALSE, ...)
glycopeptides(only_rsi_columns = FALSE, ...)
lincosamides(only_rsi_columns = FALSE, ...)
lipoglycopeptides(only_rsi_columns = FALSE, ...)
macrolides(only_rsi_columns = FALSE, ...)
oxazolidinones(only_rsi_columns = FALSE, ...)
penicillins(only_rsi_columns = FALSE, ...)
polymyxins(only_rsi_columns = FALSE, only_treatable = TRUE, ...)
streptogramins(only_rsi_columns = FALSE, ...)
quinolones(only_rsi_columns = FALSE, ...)
tetracyclines(only_rsi_columns = FALSE, ...)
trimethoprims(only_rsi_columns = FALSE, ...)
ureidopenicillins(only_rsi_columns = FALSE, ...)
administrable_per_os(only_rsi_columns = FALSE, ...)
administrable_iv(only_rsi_columns = FALSE, ...)
not_intrinsic_resistant(
only_rsi_columns = FALSE,
col_mo = NULL,
version_expertrules = 3.3,
...
)
Arguments
- ab_class
an antimicrobial class or a part of it, such as
"carba"
and"carbapenems"
. The columnsgroup
,atc_group1
andatc_group2
of the antibiotics data set will be searched (case-insensitive) for this value.- only_rsi_columns
a logical to indicate whether only columns of class
rsi
must be selected (defaults toFALSE
), seeas.rsi()
- only_treatable
a logical to indicate whether agents that are only for laboratory tests should be excluded (defaults to
TRUE
), such as gentamicin-high (GEH
) and imipenem/EDTA (IPE
)- ...
ignored, only in place to allow future extensions
- filter
an expression to be evaluated in the antibiotics data set, such as
name %like% "trim"
- col_mo
column name of the IDs of the microorganisms (see
as.mo()
), defaults to the first column of classmo
. Values will be coerced usingas.mo()
.- version_expertrules
the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be either "3.3", "3.2" or "3.1".
Value
(internally) a character vector of column names, with additional class "ab_selector"
Details
These functions can be used in data set calls for selecting columns and filtering rows. They are heavily inspired by the Tidyverse selection helpers such as everything()
, but also work in base R and not only in dplyr
verbs. Nonetheless, they are very convenient to use with dplyr
functions such as select()
, filter()
and summarise()
, see Examples.
All columns in the data in which these functions are called will be searched for known antibiotic names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) according to the antibiotics data set. This means that a selector such as aminoglycosides()
will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
The ab_class()
function can be used to filter/select on a manually defined antibiotic class. It searches for results in the antibiotics data set within the columns group
, atc_group1
and atc_group2
.
The ab_selector()
function can be used to internally filter the antibiotics data set on any results, see Examples. It allows for filtering on a (part of) a certain name, and/or a group name or even a minimum of DDDs for oral treatment. This function yields the highest flexibility, but is also the least user-friendly, since it requires a hard-coded filter to set.
The administrable_per_os()
and administrable_iv()
functions also rely on the antibiotics data set - antibiotic columns will be matched where a DDD (defined daily dose) for resp. oral and IV treatment is available in the antibiotics data set.
The not_intrinsic_resistant()
function can be used to only select antibiotic columns that pose no intrinsic resistance for the microorganisms in the data set. For example, if a data set contains only microorganism codes or names of E. coli and K. pneumoniae and contains a column "vancomycin", this column will be removed (or rather, unselected) using this function. It currently applies 'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.3 (2021) to determine intrinsic resistance, using the eucast_rules()
function internally. Because of this determination, this function is quite slow in terms of performance.
Full list of supported (antibiotic) classes
aminoglycosides()
can select:
amikacin (AMK), amikacin/fosfomycin (AKF), amphotericin B-high (AMH), apramycin (APR), arbekacin (ARB), astromicin (AST), bekanamycin (BEK), dibekacin (DKB), framycetin (FRM), gentamicin (GEN), gentamicin-high (GEH), habekacin (HAB), hygromycin (HYG), isepamicin (ISE), kanamycin (KAN), kanamycin-high (KAH), kanamycin/cephalexin (KAC), micronomicin (MCR), neomycin (NEO), netilmicin (NET), pentisomicin (PIM), plazomicin (PLZ), propikacin (PKA), ribostamycin (RST), sisomicin (SIS), streptoduocin (STR), streptomycin (STR1), streptomycin-high (STH), tobramycin (TOB) and tobramycin-high (TOH)aminopenicillins()
can select:
amoxicillin (AMX) and ampicillin (AMP)antifungals()
can select:
amphotericin B (AMB), anidulafungin (ANI), butoconazole (BUT), caspofungin (CAS), ciclopirox (CIX), clotrimazole (CTR), econazole (ECO), fluconazole (FLU), flucytosine (FCT), fosfluconazole (FFL), griseofulvin (GRI), hachimycin (HCH), ibrexafungerp (IBX), isavuconazole (ISV), isoconazole (ISO), itraconazole (ITR), ketoconazole (KET), manogepix (MGX), micafungin (MIF), miconazole (MCZ), nystatin (NYS), oteseconazole (OTE), pimaricin (PMR), posaconazole (POS), rezafungin (RZF), ribociclib (RBC), sulconazole (SUC), terbinafine (TRB), terconazole (TRC) and voriconazole (VOR)antimycobacterials()
can select:
4-aminosalicylic acid (AMA), calcium aminosalicylate (CLA), capreomycin (CAP), clofazimine (CLF), delamanid (DLM), enviomycin (ENV), ethambutol (ETH), ethambutol/isoniazid (ETI), ethionamide (ETI1), isoniazid (INH), isoniazid/sulfamethoxazole/trimethoprim/pyridoxine (IST), morinamide (MRN), p-aminosalicylic acid (PAS), pretomanid (PMD), protionamide (PTH), pyrazinamide (PZA), rifabutin (RIB), rifampicin (RIF), rifampicin/ethambutol/isoniazid (REI), rifampicin/isoniazid (RFI), rifampicin/pyrazinamide/ethambutol/isoniazid (RPEI), rifampicin/pyrazinamide/isoniazid (RPI), rifamycin (RFM), rifapentine (RFP), simvastatin/fenofibrate (SMF), sodium aminosalicylate (SDA), streptomycin/isoniazid (STI), terizidone (TRZ), thioacetazone (TAT), thioacetazone/isoniazid (THI1), tiocarlide (TCR) and viomycin (VIO)betalactams()
can select:
amoxicillin (AMX), amoxicillin/clavulanic acid (AMC), amoxicillin/sulbactam (AXS), ampicillin (AMP), ampicillin/sulbactam (SAM), apalcillin (APL), aspoxicillin (APX), avibactam (AVB), azidocillin (AZD), azlocillin (AZL), aztreonam (ATM), aztreonam/avibactam (AZA), aztreonam/nacubactam (ANC), bacampicillin (BAM), benzathine benzylpenicillin (BNB), benzathine phenoxymethylpenicillin (BNP), benzylpenicillin (PEN), biapenem (BIA), carbenicillin (CRB), carindacillin (CRN), cefacetrile (CAC), cefaclor (CEC), cefadroxil (CFR), cefalexin (LEX), cefaloridine (RID), cefalotin (CEP), cefamandole (MAN), cefapirin (HAP), cefatrizine (CTZ), cefazedone (CZD), cefazolin (CZO), cefcapene (CCP), cefcapene pivoxil (CCX), cefdinir (CDR), cefditoren (DIT), cefditoren pivoxil (DIX), cefepime (FEP), cefepime/clavulanic acid (CPC), cefepime/nacubactam (FNC), cefepime/tazobactam (FPT), cefetamet (CAT), cefetamet pivoxil (CPI), cefetecol (CCL), cefetrizole (CZL), cefixime (CFM), cefmenoxime (CMX), cefmetazole (CMZ), cefodizime (DIZ), cefonicid (CID), cefoperazone (CFP), cefoperazone/sulbactam (CSL), ceforanide (CND), cefoselis (CSE), cefotaxime (CTX), cefotaxime/clavulanic acid (CTC), cefotaxime/sulbactam (CTS), cefotetan (CTT), cefotiam (CTF), cefotiam hexetil (CHE), cefovecin (FOV), cefoxitin (FOX), cefoxitin screening (FOX1), cefozopran (ZOP), cefpimizole (CFZ), cefpiramide (CPM), cefpirome (CPO), cefpodoxime (CPD), cefpodoxime proxetil (CPX), cefpodoxime/clavulanic acid (CDC), cefprozil (CPR), cefquinome (CEQ), cefroxadine (CRD), cefsulodin (CFS), cefsumide (CSU), ceftaroline (CPT), ceftaroline/avibactam (CPA), ceftazidime (CAZ), ceftazidime/avibactam (CZA), ceftazidime/clavulanic acid (CCV), cefteram (CEM), cefteram pivoxil (CPL), ceftezole (CTL), ceftibuten (CTB), ceftiofur (TIO), ceftizoxime (CZX), ceftizoxime alapivoxil (CZP), ceftobiprole (BPR), ceftobiprole medocaril (CFM1), ceftolozane/tazobactam (CEI), ceftolozane/tazobactam (CZT), ceftriaxone (CRO), ceftriaxone/beta-lactamase inhibitor (CEB), cefuroxime (CXM), cefuroxime axetil (CXA), cephradine (CED), ciclacillin (CIC), clometocillin (CLM), cloxacillin (CLO), dicloxacillin (DIC), doripenem (DOR), epicillin (EPC), ertapenem (ETP), flucloxacillin (FLC), hetacillin (HET), imipenem (IPM), imipenem/EDTA (IPE), imipenem/relebactam (IMR), latamoxef (LTM), lenampicillin (LEN), loracarbef (LOR), mecillinam (MEC), meropenem (MEM), meropenem/nacubactam (MNC), meropenem/vaborbactam (MEV), metampicillin (MTM), meticillin (MET), mezlocillin (MEZ), mezlocillin/sulbactam (MSU), nacubactam (NAC), nafcillin (NAF), oxacillin (OXA), panipenem (PAN), penamecillin (PNM), penicillin/novobiocin (PNO), penicillin/sulbactam (PSU), pheneticillin (PHE), phenoxymethylpenicillin (PHN), piperacillin (PIP), piperacillin/sulbactam (PIS), piperacillin/tazobactam (TZP), piridicillin (PRC), pivampicillin (PVM), pivmecillinam (PME), procaine benzylpenicillin (PRB), propicillin (PRP), razupenem (RZM), ritipenem (RIT), ritipenem acoxil (RIA), sarmoxicillin (SRX), sulbactam (SUL), sulbenicillin (SBC), sultamicillin (SLT6), talampicillin (TAL), tazobactam (TAZ), tebipenem (TBP), temocillin (TEM), ticarcillin (TIC) and ticarcillin/clavulanic acid (TCC)carbapenems()
can select:
biapenem (BIA), doripenem (DOR), ertapenem (ETP), imipenem (IPM), imipenem/EDTA (IPE), imipenem/relebactam (IMR), meropenem (MEM), meropenem/nacubactam (MNC), meropenem/vaborbactam (MEV), panipenem (PAN), razupenem (RZM), ritipenem (RIT), ritipenem acoxil (RIA) and tebipenem (TBP)cephalosporins()
can select:
cefacetrile (CAC), cefaclor (CEC), cefadroxil (CFR), cefalexin (LEX), cefaloridine (RID), cefalotin (CEP), cefamandole (MAN), cefapirin (HAP), cefatrizine (CTZ), cefazedone (CZD), cefazolin (CZO), cefcapene (CCP), cefcapene pivoxil (CCX), cefdinir (CDR), cefditoren (DIT), cefditoren pivoxil (DIX), cefepime (FEP), cefepime/clavulanic acid (CPC), cefepime/tazobactam (FPT), cefetamet (CAT), cefetamet pivoxil (CPI), cefetecol (CCL), cefetrizole (CZL), cefixime (CFM), cefmenoxime (CMX), cefmetazole (CMZ), cefodizime (DIZ), cefonicid (CID), cefoperazone (CFP), cefoperazone/sulbactam (CSL), ceforanide (CND), cefoselis (CSE), cefotaxime (CTX), cefotaxime/clavulanic acid (CTC), cefotaxime/sulbactam (CTS), cefotetan (CTT), cefotiam (CTF), cefotiam hexetil (CHE), cefovecin (FOV), cefoxitin (FOX), cefoxitin screening (FOX1), cefozopran (ZOP), cefpimizole (CFZ), cefpiramide (CPM), cefpirome (CPO), cefpodoxime (CPD), cefpodoxime proxetil (CPX), cefpodoxime/clavulanic acid (CDC), cefprozil (CPR), cefquinome (CEQ), cefroxadine (CRD), cefsulodin (CFS), cefsumide (CSU), ceftaroline (CPT), ceftaroline/avibactam (CPA), ceftazidime (CAZ), ceftazidime/avibactam (CZA), ceftazidime/clavulanic acid (CCV), cefteram (CEM), cefteram pivoxil (CPL), ceftezole (CTL), ceftibuten (CTB), ceftiofur (TIO), ceftizoxime (CZX), ceftizoxime alapivoxil (CZP), ceftobiprole (BPR), ceftobiprole medocaril (CFM1), ceftolozane/tazobactam (CEI), ceftolozane/tazobactam (CZT), ceftriaxone (CRO), ceftriaxone/beta-lactamase inhibitor (CEB), cefuroxime (CXM), cefuroxime axetil (CXA), cephradine (CED), latamoxef (LTM) and loracarbef (LOR)cephalosporins_1st()
can select:
cefacetrile (CAC), cefadroxil (CFR), cefalexin (LEX), cefaloridine (RID), cefalotin (CEP), cefapirin (HAP), cefatrizine (CTZ), cefazedone (CZD), cefazolin (CZO), cefroxadine (CRD), ceftezole (CTL) and cephradine (CED)cephalosporins_2nd()
can select:
cefaclor (CEC), cefamandole (MAN), cefmetazole (CMZ), cefonicid (CID), ceforanide (CND), cefotetan (CTT), cefotiam (CTF), cefoxitin (FOX), cefoxitin screening (FOX1), cefprozil (CPR), cefuroxime (CXM), cefuroxime axetil (CXA) and loracarbef (LOR)cephalosporins_3rd()
can select:
cefcapene (CCP), cefcapene pivoxil (CCX), cefdinir (CDR), cefditoren (DIT), cefditoren pivoxil (DIX), cefetamet (CAT), cefetamet pivoxil (CPI), cefixime (CFM), cefmenoxime (CMX), cefodizime (DIZ), cefoperazone (CFP), cefoperazone/sulbactam (CSL), cefotaxime (CTX), cefotaxime/clavulanic acid (CTC), cefotaxime/sulbactam (CTS), cefotiam hexetil (CHE), cefovecin (FOV), cefpimizole (CFZ), cefpiramide (CPM), cefpodoxime (CPD), cefpodoxime proxetil (CPX), cefpodoxime/clavulanic acid (CDC), cefsulodin (CFS), ceftazidime (CAZ), ceftazidime/avibactam (CZA), ceftazidime/clavulanic acid (CCV), cefteram (CEM), cefteram pivoxil (CPL), ceftibuten (CTB), ceftiofur (TIO), ceftizoxime (CZX), ceftizoxime alapivoxil (CZP), ceftriaxone (CRO), ceftriaxone/beta-lactamase inhibitor (CEB) and latamoxef (LTM)cephalosporins_4th()
can select:
cefepime (FEP), cefepime/clavulanic acid (CPC), cefepime/tazobactam (FPT), cefetecol (CCL), cefoselis (CSE), cefozopran (ZOP), cefpirome (CPO) and cefquinome (CEQ)cephalosporins_5th()
can select:
ceftaroline (CPT), ceftaroline/avibactam (CPA), ceftobiprole (BPR), ceftobiprole medocaril (CFM1), ceftolozane/tazobactam (CEI) and ceftolozane/tazobactam (CZT)fluoroquinolones()
can select:
besifloxacin (BES), ciprofloxacin (CIP), clinafloxacin (CLX), danofloxacin (DAN), delafloxacin (DFX), difloxacin (DIF), enoxacin (ENX), enrofloxacin (ENR), finafloxacin (FIN), fleroxacin (FLE), garenoxacin (GRN), gatifloxacin (GAT), gemifloxacin (GEM), grepafloxacin (GRX), lascufloxacin (LSC), levofloxacin (LVX), levonadifloxacin (LND), lomefloxacin (LOM), marbofloxacin (MAR), metioxate (MXT), miloxacin (MIL), moxifloxacin (MFX), nadifloxacin (NAD), nifuroquine (NIF), norfloxacin (NOR), ofloxacin (OFX), orbifloxacin (ORB), pazufloxacin (PAZ), pefloxacin (PEF), pradofloxacin (PRA), premafloxacin (PRX), prulifloxacin (PRU), rufloxacin (RFL), sarafloxacin (SAR), sitafloxacin (SIT), sparfloxacin (SPX), temafloxacin (TMX), tilbroquinol (TBQ), tioxacin (TXC), tosufloxacin (TFX) and trovafloxacin (TVA)glycopeptides()
can select:
avoparcin (AVO), dalbavancin (DAL), norvancomycin (NVA), oritavancin (ORI), ramoplanin (RAM), teicoplanin (TEC), teicoplanin-macromethod (TCM), telavancin (TLV), vancomycin (VAN) and vancomycin-macromethod (VAM)lincosamides()
can select:
acetylmidecamycin (ACM), acetylspiramycin (ASP), clindamycin (CLI), gamithromycin (GAM), kitasamycin (KIT), lincomycin (LIN), meleumycin (MEL), nafithromycin (ZWK), pirlimycin (PRL), primycin (PRM), solithromycin (SOL), tildipirosin (TIP), tilmicosin (TIL), tulathromycin (TUL), tylosin (TYL) and tylvalosin (TYL1)lipoglycopeptides()
can select:
dalbavancin (DAL), oritavancin (ORI) and telavancin (TLV)macrolides()
can select:
acetylmidecamycin (ACM), acetylspiramycin (ASP), azithromycin (AZM), clarithromycin (CLR), dirithromycin (DIR), erythromycin (ERY), flurithromycin (FLR1), gamithromycin (GAM), josamycin (JOS), kitasamycin (KIT), meleumycin (MEL), midecamycin (MID), miocamycin (MCM), nafithromycin (ZWK), oleandomycin (OLE), pirlimycin (PRL), primycin (PRM), rokitamycin (ROK), roxithromycin (RXT), solithromycin (SOL), spiramycin (SPI), telithromycin (TLT), tildipirosin (TIP), tilmicosin (TIL), troleandomycin (TRL), tulathromycin (TUL), tylosin (TYL) and tylvalosin (TYL1)oxazolidinones()
can select:
cadazolid (CDZ), cycloserine (CYC), linezolid (LNZ), tedizolid (TZD) and thiacetazone (THA)penicillins()
can select:
amoxicillin (AMX), amoxicillin/clavulanic acid (AMC), amoxicillin/sulbactam (AXS), ampicillin (AMP), ampicillin/sulbactam (SAM), apalcillin (APL), aspoxicillin (APX), avibactam (AVB), azidocillin (AZD), azlocillin (AZL), aztreonam (ATM), aztreonam/avibactam (AZA), aztreonam/nacubactam (ANC), bacampicillin (BAM), benzathine benzylpenicillin (BNB), benzathine phenoxymethylpenicillin (BNP), benzylpenicillin (PEN), carbenicillin (CRB), carindacillin (CRN), cefepime/nacubactam (FNC), ciclacillin (CIC), clometocillin (CLM), cloxacillin (CLO), dicloxacillin (DIC), epicillin (EPC), flucloxacillin (FLC), hetacillin (HET), lenampicillin (LEN), mecillinam (MEC), metampicillin (MTM), meticillin (MET), mezlocillin (MEZ), mezlocillin/sulbactam (MSU), nacubactam (NAC), nafcillin (NAF), oxacillin (OXA), penamecillin (PNM), penicillin/novobiocin (PNO), penicillin/sulbactam (PSU), pheneticillin (PHE), phenoxymethylpenicillin (PHN), piperacillin (PIP), piperacillin/sulbactam (PIS), piperacillin/tazobactam (TZP), piridicillin (PRC), pivampicillin (PVM), pivmecillinam (PME), procaine benzylpenicillin (PRB), propicillin (PRP), sarmoxicillin (SRX), sulbactam (SUL), sulbenicillin (SBC), sultamicillin (SLT6), talampicillin (TAL), tazobactam (TAZ), temocillin (TEM), ticarcillin (TIC) and ticarcillin/clavulanic acid (TCC)polymyxins()
can select:
colistin (COL), polymyxin B (PLB) and polymyxin B/polysorbate 80 (POP)quinolones()
can select:
besifloxacin (BES), cinoxacin (CIN), ciprofloxacin (CIP), clinafloxacin (CLX), danofloxacin (DAN), delafloxacin (DFX), difloxacin (DIF), enoxacin (ENX), enrofloxacin (ENR), finafloxacin (FIN), fleroxacin (FLE), flumequine (FLM), garenoxacin (GRN), gatifloxacin (GAT), gemifloxacin (GEM), grepafloxacin (GRX), lascufloxacin (LSC), levofloxacin (LVX), levonadifloxacin (LND), lomefloxacin (LOM), marbofloxacin (MAR), metioxate (MXT), miloxacin (MIL), moxifloxacin (MFX), nadifloxacin (NAD), nalidixic acid (NAL), nemonoxacin (NEM), nifuroquine (NIF), nitroxoline (NTR), norfloxacin (NOR), ofloxacin (OFX), orbifloxacin (ORB), oxolinic acid (OXO), pazufloxacin (PAZ), pefloxacin (PEF), pipemidic acid (PPA), piromidic acid (PIR), pradofloxacin (PRA), premafloxacin (PRX), prulifloxacin (PRU), rosoxacin (ROS), rufloxacin (RFL), sarafloxacin (SAR), sitafloxacin (SIT), sparfloxacin (SPX), temafloxacin (TMX), tilbroquinol (TBQ), tioxacin (TXC), tosufloxacin (TFX) and trovafloxacin (TVA)streptogramins()
can select:
pristinamycin (PRI) and quinupristin/dalfopristin (QDA)tetracyclines()
can select:
cetocycline (CTO), chlortetracycline (CTE), clomocycline (CLM1), demeclocycline (DEM), doxycycline (DOX), eravacycline (ERV), lymecycline (LYM), metacycline (MTC), minocycline (MNO), omadacycline (OMC), oxytetracycline (OXY), penimepicycline (PNM1), rolitetracycline (RLT), sarecycline (SRC), tetracycline (TCY) and tigecycline (TGC)trimethoprims()
can select:
brodimoprim (BDP), sulfadiazine (SDI), sulfadiazine/tetroxoprim (SLT), sulfadiazine/trimethoprim (SLT1), sulfadimethoxine (SUD), sulfadimidine (SDM), sulfadimidine/trimethoprim (SLT2), sulfafurazole (SLF), sulfaisodimidine (SLF1), sulfalene (SLF2), sulfamazone (SZO), sulfamerazine (SLF3), sulfamerazine/trimethoprim (SLT3), sulfamethizole (SLF4), sulfamethoxazole (SMX), sulfamethoxypyridazine (SLF5), sulfametomidine (SLF6), sulfametoxydiazine (SLF7), sulfametrole/trimethoprim (SLT4), sulfamoxole (SLF8), sulfamoxole/trimethoprim (SLT5), sulfanilamide (SLF9), sulfaperin (SLF10), sulfaphenazole (SLF11), sulfapyridine (SLF12), sulfathiazole (SUT), sulfathiourea (SLF13), trimethoprim (TMP) and trimethoprim/sulfamethoxazole (SXT)ureidopenicillins()
can select:
azlocillin (AZL), mezlocillin (MEZ), piperacillin (PIP) and piperacillin/tazobactam (TZP)
Reference Data Publicly Available
All data sets in this AMR
package (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) are publicly and freely available for download in the following formats: R, MS Excel, Apache Feather, Apache Parquet, SPSS, SAS, and Stata. We also provide tab-separated plain text files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please visit our website for the download links. The actual files are of course available on our GitHub repository.
Examples
# `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> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 1,990 more rows, and 36 more variables: AMC <rsi>, AMP <rsi>,
#> # TZP <rsi>, CZO <rsi>, FEP <rsi>, CXM <rsi>, FOX <rsi>, CTX <rsi>,
#> # CAZ <rsi>, CRO <rsi>, GEN <rsi>, TOB <rsi>, AMK <rsi>, KAN <rsi>,
#> # TMP <rsi>, SXT <rsi>, NIT <rsi>, FOS <rsi>, LNZ <rsi>, CIP <rsi>,
#> # MFX <rsi>, VAN <rsi>, TEC <rsi>, TCY <rsi>, TGC <rsi>, DOX <rsi>,
#> # ERY <rsi>, CLI <rsi>, AZM <rsi>, IPM <rsi>, MEM <rsi>, MTR <rsi>,
#> # CHL <rsi>, COL <rsi>, MUP <rsi>, RIF <rsi>
# 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
#> <rsi> <rsi>
#> 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
#> # … with 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> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 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
#> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 1,990 more rows, and 10 more variables: VAN <rsi>, TCY <rsi>,
#> # DOX <rsi>, ERY <rsi>, CLI <rsi>, AZM <rsi>, MTR <rsi>, CHL <rsi>,
#> # COL <rsi>, RIF <rsi>
# 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> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 45 more rows, and 36 more variables: AMC <rsi>, AMP <rsi>, TZP <rsi>,
#> # CZO <rsi>, FEP <rsi>, CXM <rsi>, FOX <rsi>, CTX <rsi>, CAZ <rsi>,
#> # CRO <rsi>, GEN <rsi>, TOB <rsi>, AMK <rsi>, KAN <rsi>, TMP <rsi>,
#> # SXT <rsi>, NIT <rsi>, FOS <rsi>, LNZ <rsi>, CIP <rsi>, MFX <rsi>,
#> # VAN <rsi>, TEC <rsi>, TCY <rsi>, TGC <rsi>, DOX <rsi>, ERY <rsi>,
#> # CLI <rsi>, AZM <rsi>, IPM <rsi>, MEM <rsi>, MTR <rsi>, CHL <rsi>,
#> # COL <rsi>, MUP <rsi>, RIF <rsi>
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> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 45 more rows, and 36 more variables: AMC <rsi>, AMP <rsi>, TZP <rsi>,
#> # CZO <rsi>, FEP <rsi>, CXM <rsi>, FOX <rsi>, CTX <rsi>, CAZ <rsi>,
#> # CRO <rsi>, GEN <rsi>, TOB <rsi>, AMK <rsi>, KAN <rsi>, TMP <rsi>,
#> # SXT <rsi>, NIT <rsi>, FOS <rsi>, LNZ <rsi>, CIP <rsi>, MFX <rsi>,
#> # VAN <rsi>, TEC <rsi>, TCY <rsi>, TGC <rsi>, DOX <rsi>, ERY <rsi>,
#> # CLI <rsi>, AZM <rsi>, IPM <rsi>, MEM <rsi>, MTR <rsi>, CHL <rsi>,
#> # COL <rsi>, MUP <rsi>, RIF <rsi>
# 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 "R", "S" or "I"
#> # A tibble: 962 × 46
#> date patient age gender ward mo PEN OXA FLC AMX
#> <date> <chr> <dbl> <chr> <chr> <mo> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 952 more rows, and 36 more variables: AMC <rsi>, AMP <rsi>, TZP <rsi>,
#> # CZO <rsi>, FEP <rsi>, CXM <rsi>, FOX <rsi>, CTX <rsi>, CAZ <rsi>,
#> # CRO <rsi>, GEN <rsi>, TOB <rsi>, AMK <rsi>, KAN <rsi>, TMP <rsi>,
#> # SXT <rsi>, NIT <rsi>, FOS <rsi>, LNZ <rsi>, CIP <rsi>, MFX <rsi>,
#> # VAN <rsi>, TEC <rsi>, TCY <rsi>, TGC <rsi>, DOX <rsi>, ERY <rsi>,
#> # CLI <rsi>, AZM <rsi>, IPM <rsi>, MEM <rsi>, MTR <rsi>, CHL <rsi>,
#> # COL <rsi>, MUP <rsi>, RIF <rsi>
example_isolates[all(carbapenems()), ]
#> ℹ For `carbapenems()` using columns 'IPM' (imipenem) and 'MEM' (meropenem)
#> ℹ Filtering all of columns 'IPM' and 'MEM' to contain value "R", "S" or "I"
#> # A tibble: 756 × 46
#> date patient age gender ward mo PEN OXA FLC AMX
#> <date> <chr> <dbl> <chr> <chr> <mo> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 746 more rows, and 36 more variables: AMC <rsi>, AMP <rsi>, TZP <rsi>,
#> # CZO <rsi>, FEP <rsi>, CXM <rsi>, FOX <rsi>, CTX <rsi>, CAZ <rsi>,
#> # CRO <rsi>, GEN <rsi>, TOB <rsi>, AMK <rsi>, KAN <rsi>, TMP <rsi>,
#> # SXT <rsi>, NIT <rsi>, FOS <rsi>, LNZ <rsi>, CIP <rsi>, MFX <rsi>,
#> # VAN <rsi>, TEC <rsi>, TCY <rsi>, TGC <rsi>, DOX <rsi>, ERY <rsi>,
#> # CLI <rsi>, AZM <rsi>, IPM <rsi>, MEM <rsi>, MTR <rsi>, CHL <rsi>,
#> # COL <rsi>, MUP <rsi>, RIF <rsi>
# 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> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 16 more rows, and 36 more variables: AMC <rsi>, AMP <rsi>, TZP <rsi>,
#> # CZO <rsi>, FEP <rsi>, CXM <rsi>, FOX <rsi>, CTX <rsi>, CAZ <rsi>,
#> # CRO <rsi>, GEN <rsi>, TOB <rsi>, AMK <rsi>, KAN <rsi>, TMP <rsi>,
#> # SXT <rsi>, NIT <rsi>, FOS <rsi>, LNZ <rsi>, CIP <rsi>, MFX <rsi>,
#> # VAN <rsi>, TEC <rsi>, TCY <rsi>, TGC <rsi>, DOX <rsi>, ERY <rsi>,
#> # CLI <rsi>, AZM <rsi>, IPM <rsi>, MEM <rsi>, MTR <rsi>, CHL <rsi>,
#> # COL <rsi>, MUP <rsi>, RIF <rsi>
# filter + select in one go: get penicillins in carbapenems-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
#> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 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
#> <rsi> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 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
#> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 1,990 more rows
# dplyr -------------------------------------------------------------------
# \donttest{
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: 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
#> <rsi> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 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: Introducing NA: no results available for OXA in group: ward = "Clinical"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for OXA in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for OXA in group: ward = "Outpatient"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for FLC in group: ward = "Clinical"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for FLC in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for FLC in group: ward = "Outpatient"
#> (`minimum` = 30).
#> Warning: Introducing NA: only 25 results available for AMX in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 27 results available for AMC in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 25 results available for AMP in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 24 results available for TZP in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 23 results available for CZO in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: only 10 results available for CZO in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 20 results available for FEP in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 27 results available for CXM in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 22 results available for FOX in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 25 results available for CTX in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 27 results available for CAZ in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 25 results available for CRO in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 27 results available for GEN in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 27 results available for TOB in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 15 results available for AMK in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: no results available for KAN in group: ward = "Clinical"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for KAN in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for KAN in group: ward = "Outpatient"
#> (`minimum` = 30).
#> Warning: Introducing NA: only 22 results available for TMP in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 27 results available for SXT in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 27 results available for NIT in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 25 results available for FOS in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: only 2 results available for FOS in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 27 results available for CIP in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 15 results available for MFX in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: only 4 results available for MFX in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 5 results available for TCY in group: ward =
#> "Clinical" (`minimum` = 30).
#> Warning: Introducing NA: no results available for TCY in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for TCY in group: ward = "Outpatient"
#> (`minimum` = 30).
#> Warning: Introducing NA: only 13 results available for TGC in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: only 2 results available for TGC in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: no results available for DOX in group: ward = "Clinical"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for DOX in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for DOX in group: ward = "Outpatient"
#> (`minimum` = 30).
#> Warning: Introducing NA: only 24 results available for IPM in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 25 results available for MEM in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: only 2 results available for MTR in group: ward =
#> "Clinical" (`minimum` = 30).
#> Warning: Introducing NA: no results available for MTR in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for MTR in group: ward = "Outpatient"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for CHL in group: ward = "Clinical"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for CHL in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for CHL in group: ward = "Outpatient"
#> (`minimum` = 30).
#> Warning: Introducing NA: only 9 results available for COL in group: ward =
#> "Outpatient" (`minimum` = 30).
#> Warning: Introducing NA: no results available for MUP in group: ward = "Clinical"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for MUP in group: ward = "ICU"
#> (`minimum` = 30).
#> Warning: Introducing NA: no results available for MUP in group: ward = "Outpatient"
#> (`minimum` = 30).
#> # 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
#> # … with 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))
}
#> Including isolates from ICU.
#> ℹ 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.808
#> 2 ICU 0.549 0.778
#> 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
#> <rsi> <rsi>
#> 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
#> # … with 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> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 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> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 102 more rows, and 36 more variables: AMC <rsi>, AMP <rsi>, TZP <rsi>,
#> # CZO <rsi>, FEP <rsi>, CXM <rsi>, FOX <rsi>, CTX <rsi>, CAZ <rsi>,
#> # CRO <rsi>, GEN <rsi>, TOB <rsi>, AMK <rsi>, KAN <rsi>, TMP <rsi>,
#> # SXT <rsi>, NIT <rsi>, FOS <rsi>, LNZ <rsi>, CIP <rsi>, MFX <rsi>,
#> # VAN <rsi>, TEC <rsi>, TCY <rsi>, TGC <rsi>, DOX <rsi>, ERY <rsi>,
#> # CLI <rsi>, AZM <rsi>, IPM <rsi>, MEM <rsi>, MTR <rsi>, CHL <rsi>,
#> # COL <rsi>, MUP <rsi>, RIF <rsi>
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> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 521 more rows, and 36 more variables: AMC <rsi>, AMP <rsi>, TZP <rsi>,
#> # CZO <rsi>, FEP <rsi>, CXM <rsi>, FOX <rsi>, CTX <rsi>, CAZ <rsi>,
#> # CRO <rsi>, GEN <rsi>, TOB <rsi>, AMK <rsi>, KAN <rsi>, TMP <rsi>,
#> # SXT <rsi>, NIT <rsi>, FOS <rsi>, LNZ <rsi>, CIP <rsi>, MFX <rsi>,
#> # VAN <rsi>, TEC <rsi>, TCY <rsi>, TGC <rsi>, DOX <rsi>, ERY <rsi>,
#> # CLI <rsi>, AZM <rsi>, IPM <rsi>, MEM <rsi>, MTR <rsi>, CHL <rsi>,
#> # COL <rsi>, MUP <rsi>, RIF <rsi>
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> <rsi> <rsi> <rsi> <rsi>
#> 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
#> # … with 417 more rows, and 36 more variables: AMC <rsi>, AMP <rsi>, TZP <rsi>,
#> # CZO <rsi>, FEP <rsi>, CXM <rsi>, FOX <rsi>, CTX <rsi>, CAZ <rsi>,
#> # CRO <rsi>, GEN <rsi>, TOB <rsi>, AMK <rsi>, KAN <rsi>, TMP <rsi>,
#> # SXT <rsi>, NIT <rsi>, FOS <rsi>, LNZ <rsi>, CIP <rsi>, MFX <rsi>,
#> # VAN <rsi>, TEC <rsi>, TCY <rsi>, TGC <rsi>, DOX <rsi>, ERY <rsi>,
#> # CLI <rsi>, AZM <rsi>, IPM <rsi>, MEM <rsi>, MTR <rsi>, CHL <rsi>,
#> # COL <rsi>, MUP <rsi>, RIF <rsi>
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> <rsi>
#> 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
#> # … with 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)
#> ℹ Using column 'mo' as input for `col_mo`.
#> # A tibble: 2 × 8
#> Group Drug CoNS E. fa…¹ S. au…² S. ep…³ S. ho…⁴ S. pn…⁵
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 "Glycopeptides" Teicoplanin (TE… "" "" " 0.0%… "64.1%… " 6.8%… ""
#> 2 "" Vancomycin (VAN… " 0.… " 0.0%… " 0.0%… " 0.0%… " 0.0%… " 0.0%…
#> # … with abbreviated variable names ¹`E. faecalis`, ²`S. aureus`,
#> # ³`S. epidermidis`, ⁴`S. hominis`, ⁵`S. pneumoniae`
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
# }