2020-06-17 01:39:30 +02:00
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ab_class_selectors.R
\name{antibiotic_class_selectors}
\alias{antibiotic_class_selectors}
2020-06-17 15:14:37 +02:00
\alias{ab_class}
2020-06-17 01:39:30 +02:00
\alias{aminoglycosides}
2021-06-04 21:07:55 +02:00
\alias{aminopenicillins}
2021-05-18 00:53:04 +02:00
\alias{betalactams}
2020-06-17 01:39:30 +02:00
\alias{carbapenems}
\alias{cephalosporins}
\alias{cephalosporins_1st}
\alias{cephalosporins_2nd}
\alias{cephalosporins_3rd}
\alias{cephalosporins_4th}
\alias{cephalosporins_5th}
\alias{fluoroquinolones}
\alias{glycopeptides}
2021-06-04 21:07:55 +02:00
\alias{lincosamides}
\alias{lipoglycopeptides}
2020-06-17 01:39:30 +02:00
\alias{macrolides}
2021-02-08 14:18:42 +01:00
\alias{oxazolidinones}
2020-06-17 01:39:30 +02:00
\alias{penicillins}
2021-06-04 21:07:55 +02:00
\alias{polymyxins}
\alias{streptogramins}
\alias{quinolones}
2020-06-17 01:39:30 +02:00
\alias{tetracyclines}
2021-06-04 21:07:55 +02:00
\alias{ureidopenicillins}
2021-01-18 16:57:56 +01:00
\title{Antibiotic Class Selectors}
2020-06-17 01:39:30 +02:00
\usage{
2021-02-08 14:18:42 +01:00
ab_class(ab_class, only_rsi_columns = FALSE)
2020-06-17 15:14:37 +02:00
2021-02-08 14:18:42 +01:00
aminoglycosides(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-06-04 21:07:55 +02:00
aminopenicillins(only_rsi_columns = FALSE)
2021-05-18 00:53:04 +02:00
betalactams(only_rsi_columns = FALSE)
2021-02-08 14:18:42 +01:00
carbapenems(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
cephalosporins(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
cephalosporins_1st(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
cephalosporins_2nd(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
cephalosporins_3rd(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
cephalosporins_4th(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
cephalosporins_5th(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
fluoroquinolones(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
glycopeptides(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-06-04 21:07:55 +02:00
lincosamides(only_rsi_columns = FALSE)
lipoglycopeptides(only_rsi_columns = FALSE)
2021-02-08 14:18:42 +01:00
macrolides(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
oxazolidinones(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
2021-02-08 14:18:42 +01:00
penicillins(only_rsi_columns = FALSE)
2021-06-04 21:07:55 +02:00
polymyxins(only_rsi_columns = FALSE)
streptogramins(only_rsi_columns = FALSE)
quinolones(only_rsi_columns = FALSE)
2021-02-08 14:18:42 +01:00
tetracyclines(only_rsi_columns = FALSE)
2021-06-04 21:07:55 +02:00
ureidopenicillins(only_rsi_columns = FALSE)
2020-06-17 01:39:30 +02:00
}
2020-06-17 15:14:37 +02:00
\arguments{
2021-05-23 23:11:16 +02:00
\item{ab_class}{an antimicrobial class, such as \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.}
2021-02-02 23:57:35 +01:00
2021-05-12 18:15:03 +02:00
\item{only_rsi_columns}{a \link{logical} to indicate whether only columns of class \verb{<rsi>} must be selected (defaults to \code{FALSE}), see \code{\link[=as.rsi]{as.rsi()}}}
2020-06-17 15:14:37 +02:00
}
2020-06-17 01:39:30 +02:00
\description{
2021-06-22 12:16:42 +02:00
These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
2020-06-17 01:39:30 +02:00
}
\details{
2021-06-22 12:16:42 +02:00
These functions can be used in data set calls for selecting columns and filtering rows. They are heavily inspired by the \href{https://tidyselect.r-lib.org/reference/language.html}{Tidyverse selection helpers}, but also work in base \R and not only in \code{dplyr} verbs. Nonetheless, they are very convenient to use with \code{dplyr} functions such as \code{\link[dplyr:select]{select()}}, \code{\link[dplyr:filter]{filter()}} and \code{\link[dplyr:summarise]{summarise()}}, see \emph{Examples}.
2021-05-19 22:55:42 +02:00
2021-06-04 21:07:55 +02:00
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.) in the \link{antibiotics} data set. This means that a selector such as \code{\link[=aminoglycosides]{aminoglycosides()}} will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. Use the \code{\link[=ab_class]{ab_class()}} function to filter/select on a manually defined antibiotic class.
}
\section{Full list of supported agents}{
\itemize{
\item \code{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)
\item \code{aminopenicillins()} can select amoxicillin (AMX) and ampicillin (AMP)
\item \code{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), bacampicillin (BAM), benzathine benzylpenicillin (BNB), benzathine phenoxymethylpenicillin (BNP), benzylpenicillin (PEN), biapenem (BIA), cadazolid (CDZ), carbenicillin (CRB), carindacillin (CRN), cefacetrile (CAC), cefaclor (CEC), cefadroxil (CFR), cefaloridine (RID), cefamandole (MAN), 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 (Cefcatacol) (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/enzyme inhibitor (CEI), ceftolozane/tazobactam (CZT), ceftriaxone (CRO), cefuroxime (CXM), cefuroxime axetil (CXA), cephalexin (LEX), cephalothin (CEP), cephapirin (HAP), 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 (Amdinocillin) (MEC), meropenem (MEM), meropenem/nacubactam (MNC), meropenem/vaborbactam (MEV), metampicillin (MTM), methicillin (MET), mezlocillin (MEZ), mezlocillin/sulbactam (MSU), nacubactam (NAC), nafcillin (NAF), oxacillin (OXA), panipenem (PAN), penamecillin (PNM), penicillin/novobiocin (PNO), penicillin/sulbactam (PSU), phenethicillin (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)
\item \code{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)
\item \code{cephalosporins()} can select cadazolid (CDZ), cefacetrile (CAC), cefaclor (CEC), cefadroxil (CFR), cefaloridine (RID), cefamandole (MAN), 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 (Cefcatacol) (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/enzyme inhibitor (CEI), ceftolozane/tazobactam (CZT), ceftriaxone (CRO), cefuroxime (CXM), cefuroxime axetil (CXA), cephalexin (LEX), cephalothin (CEP), cephapirin (HAP), cephradine (CED), latamoxef (LTM) and loracarbef (LOR)
\item \code{cephalosporins_1st()} can select cefacetrile (CAC), cefadroxil (CFR), cefaloridine (RID), cefatrizine (CTZ), cefazedone (CZD), cefazolin (CZO), cefroxadine (CRD), ceftezole (CTL), cephalexin (LEX), cephalothin (CEP), cephapirin (HAP) and cephradine (CED)
\item \code{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)
\item \code{cephalosporins_3rd()} can select cadazolid (CDZ), 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) and latamoxef (LTM)
\item \code{cephalosporins_4th()} can select cefepime (FEP), cefepime/clavulanic acid (CPC), cefepime/tazobactam (FPT), cefetecol (Cefcatacol) (CCL), cefoselis (CSE), cefozopran (ZOP), cefpirome (CPO) and cefquinome (CEQ)
\item \code{cephalosporins_5th()} can select ceftaroline (CPT), ceftaroline/avibactam (CPA), ceftobiprole (BPR), ceftobiprole medocaril (CFM1), ceftolozane/enzyme inhibitor (CEI) and ceftolozane/tazobactam (CZT)
\item \code{fluoroquinolones()} can select ciprofloxacin (CIP), enoxacin (ENX), fleroxacin (FLE), gatifloxacin (GAT), gemifloxacin (GEM), grepafloxacin (GRX), levofloxacin (LVX), lomefloxacin (LOM), moxifloxacin (MFX), norfloxacin (NOR), ofloxacin (OFX), pazufloxacin (PAZ), pefloxacin (PEF), prulifloxacin (PRU), rufloxacin (RFL), sparfloxacin (SPX), temafloxacin (TMX) and trovafloxacin (TVA)
\item \code{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)
\item \code{lincosamides()} can select clindamycin (CLI), lincomycin (LIN) and pirlimycin (PRL)
\item \code{lipoglycopeptides()} can select dalbavancin (DAL), oritavancin (ORI) and telavancin (TLV)
\item \code{macrolides()} can select azithromycin (AZM), clarithromycin (CLR), dirithromycin (DIR), erythromycin (ERY), flurithromycin (FLR1), josamycin (JOS), midecamycin (MID), miocamycin (MCM), oleandomycin (OLE), rokitamycin (ROK), roxithromycin (RXT), spiramycin (SPI), telithromycin (TLT) and troleandomycin (TRL)
\item \code{oxazolidinones()} can select cycloserine (CYC), linezolid (LNZ), tedizolid (TZD) and thiacetazone (THA)
\item \code{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), bacampicillin (BAM), benzathine benzylpenicillin (BNB), benzathine phenoxymethylpenicillin (BNP), benzylpenicillin (PEN), carbenicillin (CRB), carindacillin (CRN), ciclacillin (CIC), clometocillin (CLM), cloxacillin (CLO), dicloxacillin (DIC), epicillin (EPC), flucloxacillin (FLC), hetacillin (HET), lenampicillin (LEN), mecillinam (Amdinocillin) (MEC), metampicillin (MTM), methicillin (MET), mezlocillin (MEZ), mezlocillin/sulbactam (MSU), nacubactam (NAC), nafcillin (NAF), oxacillin (OXA), penamecillin (PNM), penicillin/novobiocin (PNO), penicillin/sulbactam (PSU), phenethicillin (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)
\item \code{polymyxins()} can select colistin (COL), polymyxin B (PLB) and polymyxin B/polysorbate 80 (POP)
\item \code{streptogramins()} can select pristinamycin (PRI) and quinupristin/dalfopristin (QDA)
\item \code{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), levofloxacin (LVX), levonadifloxacin (LND), lomefloxacin (LOM), marbofloxacin (MAR), metioxate (MXT), miloxacin (MIL), moxifloxacin (MFX), nadifloxacin (NAD), nalidixic acid (NAL), 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)
\item \code{tetracyclines()} can select chlortetracycline (CTE), clomocycline (CLM1), demeclocycline (DEM), doxycycline (DOX), eravacycline (ERV), lymecycline (LYM), metacycline (MTC), minocycline (MNO), oxytetracycline (OXY), penimepicycline (PNM1), rolitetracycline (RLT), tetracycline (TCY) and tigecycline (TGC)
\item \code{ureidopenicillins()} can select azlocillin (AZL), mezlocillin (MEZ), piperacillin (PIP) and piperacillin/tazobactam (TZP)
}
2020-06-17 01:39:30 +02:00
}
2021-06-04 21:07:55 +02:00
2021-01-18 16:57:56 +01:00
\section{Stable Lifecycle}{
\if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr}
The \link[=lifecycle]{lifecycle} of this function is \strong{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.
}
\section{Reference Data Publicly Available}{
2020-08-26 16:13:40 +02:00
All reference data sets (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) in this \code{AMR} package are publicly and freely available. We continually export our data sets to formats for use in R, SPSS, SAS, Stata and Excel. We also supply flat files that are machine-readable and suitable for input in any software program, such as laboratory information systems. Please find \href{https://msberends.github.io/AMR/articles/datasets.html}{all download links on our website}, which is automatically updated with every code change.
}
2021-01-18 16:57:56 +01:00
\section{Read more on Our Website!}{
2020-08-21 11:40:13 +02:00
2021-06-01 15:33:06 +02:00
On our website \url{https://msberends.github.io/AMR/} you can find \href{https://msberends.github.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR data analysis, the \href{https://msberends.github.io/AMR/reference/}{complete documentation of all functions} and \href{https://msberends.github.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}.
2020-08-21 11:40:13 +02:00
}
2020-06-17 01:39:30 +02:00
\examples{
2021-01-24 14:48:56 +01:00
# `example_isolates` is a data set available in the AMR package.
2020-12-27 20:32:40 +01:00
# See ?example_isolates.
2021-06-04 21:07:55 +02:00
# base R ------------------------------------------------------------------
2021-05-19 22:55:42 +02:00
# select columns 'IPM' (imipenem) and 'MEM' (meropenem)
2021-02-17 10:58:13 +01:00
example_isolates[, carbapenems()]
2021-05-19 22:55:42 +02:00
# select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'
2020-12-27 20:32:40 +01:00
example_isolates[, c("mo", aminoglycosides())]
2021-05-19 22:55:42 +02:00
# filter using any() or all()
example_isolates[any(carbapenems() == "R"), ]
subset(example_isolates, any(carbapenems() == "R"))
# filter on any or all results in the carbapenem columns (i.e., IPM, MEM):
example_isolates[any(carbapenems()), ]
example_isolates[all(carbapenems()), ]
# filter with multiple antibiotic selectors using c()
example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ]
# filter + select in one go: get penicillins in carbapenems-resistant strains
example_isolates[any(carbapenems() == "R"), penicillins()]
# dplyr -------------------------------------------------------------------
2021-05-24 09:00:11 +02:00
\donttest{
2020-09-29 23:35:46 +02:00
if (require("dplyr")) {
2020-06-17 01:39:30 +02:00
2021-06-03 15:19:21 +02:00
# get AMR for all aminoglycosides e.g., per hospital:
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(across(aminoglycosides(), resistance))
2020-06-17 01:39:30 +02:00
# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
example_isolates \%>\%
select(carbapenems())
# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
example_isolates \%>\%
select(mo, aminoglycosides())
2021-05-19 22:55:42 +02:00
# any() and all() work in dplyr's filter() too:
example_isolates \%>\%
filter(any(aminoglycosides() == "R"),
all(cephalosporins_2nd() == "R"))
# also works with c():
example_isolates \%>\%
filter(any(c(carbapenems(), aminoglycosides()) == "R"))
# not setting any/all will automatically apply all():
example_isolates \%>\%
filter(aminoglycosides() == "R")
#> i Assuming a filter on all 4 aminoglycosides.
2020-06-17 15:14:37 +02:00
# this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
example_isolates \%>\%
select(mo, ab_class("mycobact"))
# get bug/drug combinations for only macrolides in Gram-positives:
example_isolates \%>\%
2020-11-16 11:03:24 +01:00
filter(mo_is_gram_positive()) \%>\%
2020-06-17 15:14:37 +02:00
select(mo, macrolides()) \%>\%
bug_drug_combinations() \%>\%
format()
2020-09-29 23:35:46 +02:00
data.frame(some_column = "some_value",
2020-06-17 01:39:30 +02:00
J01CA01 = "S") \%>\% # ATC code of ampicillin
2020-09-29 23:35:46 +02:00
select(penicillins()) # only the 'J01CA01' column will be selected
2020-12-27 23:19:41 +01:00
2021-05-19 22:55:42 +02:00
# with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal:
example_isolates[carbapenems() == "R", ]
example_isolates \%>\% filter(carbapenems() == "R")
example_isolates \%>\% filter(across(carbapenems(), ~.x == "R"))
2020-06-17 01:39:30 +02:00
}
}
2021-05-24 09:00:11 +02:00
}