This tries to find a column name in a data set based on information from the antimicrobials data set. Also supports WHONET abbreviations.
Arguments
- x
- A data.frame. 
- search_string
- A text to search - xfor, 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 antibiotic columns must be detected that were transformed to class - sir(see- as.sir()) on beforehand (default is- FALSE).
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.
Examples
df <- data.frame(
  amox = "S",
  tetr = "R"
)
guess_ab_col(df, "amoxicillin")
#> [1] "amox"
guess_ab_col(df, "J01AA07") # ATC code of tetracycline
#> [1] "tetr"
guess_ab_col(df, "J01AA07", verbose = TRUE)
#> Auto-guessing columns suitable for analysis
#> ...
#>  OK.
#> ℹ Using column 'amox' as input for AMX (amoxicillin).
#> ℹ Using column 'tetr' as input for TCY (tetracycline).
#> ℹ Using column 'tetr' as input for J01AA07 (tetracycline).
#> [1] "tetr"
# WHONET codes
df <- data.frame(
  AMP_ND10 = "R",
  AMC_ED20 = "S"
)
guess_ab_col(df, "ampicillin")
#> [1] "AMP_ND10"
guess_ab_col(df, "J01CR02")
#> [1] "AMC_ED20"
guess_ab_col(df, "augmentin")
#> [1] "AMC_ED20"