guess_ab_col: Guess Antibiotic Column

View source: R/guess_ab_col.R

guess_ab_colR Documentation

Guess Antibiotic Column

Description

This tries to find a column name in a data set based on information from the antimicrobials data set. Also supports WHONET abbreviations.

Usage

guess_ab_col(x = NULL, search_string = NULL, verbose = FALSE,
  only_sir_columns = FALSE)

Arguments

x

A data.frame.

search_string

A text to search x for, will be checked with as.ab() if this value is not a column in x.

verbose

A logical to indicate whether additional info should be printed.

only_sir_columns

A logical to indicate whether only antimicrobial columns must be included that were transformed to class sir on beforehand. Defaults to FALSE if no columns of x have a class sir.

Details

You can look for an antibiotic (trade) name or abbreviation and it will search x and the antimicrobials data set for any column containing a name or code of that antibiotic.

Value

A column name of x, or NULL when no result is found.

Examples

df <- data.frame(
  amox = "S",
  tetr = "R"
)

guess_ab_col(df, "amoxicillin")
guess_ab_col(df, "J01AA07") # ATC code of tetracycline

guess_ab_col(df, "J01AA07", verbose = TRUE)

# WHONET codes
df <- data.frame(
  AMP_ND10 = "R",
  AMC_ED20 = "S"
)
guess_ab_col(df, "ampicillin")
guess_ab_col(df, "J01CR02")
guess_ab_col(df, "augmentin")

AMR documentation built on June 8, 2025, 10:17 a.m.