These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
ab_class(ab_class, only_rsi_columns = FALSE) aminoglycosides(only_rsi_columns = FALSE) betalactams(only_rsi_columns = FALSE) carbapenems(only_rsi_columns = FALSE) 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) macrolides(only_rsi_columns = FALSE) oxazolidinones(only_rsi_columns = FALSE) penicillins(only_rsi_columns = FALSE) tetracyclines(only_rsi_columns = FALSE)
ab_class | an antimicrobial class, such as |
---|---|
only_rsi_columns | a logical to indicate whether only columns of class |
These functions can be used in data set calls for selecting columns and filtering rows, see Examples. They support base R, but work more convenient in dplyr functions such as select()
, filter()
and summarise()
.
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 antibiotics data set. This means that a selector like e.g. aminoglycosides()
will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
The group of betalactams consists of all carbapenems, cephalosporins and penicillins.
The lifecycle of this function is 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.
All reference data sets (about microorganisms, antibiotics, R/SI interpretation, EUCAST rules, etc.) in this 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 all download links on our website, which is automatically updated with every code change.
On our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR data analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!
# `example_isolates` is a data set available in the AMR package. # See ?example_isolates. # Base R ------------------------------------------------------------------ # select columns 'IPM' (imipenem) and 'MEM' (meropenem) example_isolates[, carbapenems()] # select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB' example_isolates[, c("mo", aminoglycosides())] # 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 ------------------------------------------------------------------- if (require("dplyr")) { # 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()) # 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. # 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 %>% filter(mo_is_gram_positive()) %>% select(mo, macrolides()) %>% bug_drug_combinations() %>% format() data.frame(some_column = "some_value", J01CA01 = "S") %>% # ATC code of ampicillin select(penicillins()) # only the 'J01CA01' column will be selected # with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal: # (though the row names on the first are more correct) example_isolates[carbapenems() == "R", ] example_isolates %>% filter(carbapenems() == "R") example_isolates %>% filter(across(carbapenems(), ~.x == "R")) }