Use this function to determine the antibiotic code of one or more antibiotics. The data set antibiotics will be searched for abbreviations, official names and synonyms (brand names).

as.ab(x, flag_multiple_results = TRUE, ...)




character vector to determine to antibiotic ID


logical to indicate whether a note should be printed to the console that probably more than one antibiotic code or name can be retrieved from a single input value.


arguments passed on to internal functions


Character (vector) with class ab. Unknown values will return NA.


All entries in the antibiotics data set have three different identifiers: a human readable EARS-Net code (column ab, used by ECDC and WHONET), an ATC code (column atc, used by WHO), and a CID code (column cid, Compound ID, used by PubChem). The data set contains more than 5,000 official brand names from many different countries, as found in PubChem.

All these properties will be searched for the user input. The as.ab() can correct for different forms of misspelling:

  • Wrong spelling of drug names (like "tobramicin" or "gentamycin"), which corrects for most audible similarities such as f/ph, x/ks, c/z/s, t/th, etc.

  • Too few or too many vowels or consonants

  • Switching two characters (like "mreopenem", often the case in clinical data, when doctors typed too fast)

  • Digitalised paper records, leaving artefacts like 0/o/O (zero and O's), B/8, n/r, etc.

Use the ab_property() functions to get properties based on the returned antibiotic ID, see Examples.


World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology:

WHONET 2019 software:


Maturing lifecycle

The lifecycle of this function is maturing. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome to suggest changes at our repository or write us an email (see section 'Contact Us').


This package contains all ~550 antibiotic, antimycotic and antiviral drugs and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, and the Pharmaceuticals Community Register of the European Commission (

These have become the gold standard for international drug utilisation monitoring and research.

The WHOCC is located in Oslo at the Norwegian Institute of Public Health and funded by the Norwegian government. The European Commission is the executive of the European Union and promotes its general interest.

NOTE: The WHOCC copyright does not allow use for commercial purposes, unlike any other info from this package. See

Read more on our website!

On our website you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.

See also

  • antibiotics for the dataframe that is being used to determine ATCs

  • ab_from_text() for a function to retrieve antimicrobial drugs from clinical text (from health care records)


# these examples all return "ERY", the ID of erythromycin:
as.ab("J 01 FA 01")
as.ab("   eryt 123")
as.ab("eritromicine") # spelled wrong, yet works
as.ab("Erythrocin")   # trade name
as.ab("Romycin")      # trade name

# spelling from different languages and dyslexia are no problem
ab_atc("cephtriaxone")     # small spelling error
ab_atc("cephthriaxone")    # or a bit more severe
ab_atc("seephthriaaksone") # and even this works

# use ab_* functions to get a specific properties (see ?ab_property);
# they use as.ab() internally:
ab_name("J01FA01")    # "Erythromycin"
ab_name("eryt")       # "Erythromycin"