1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-10 04:21:59 +02:00

(v2.1.1.9223) allow + ab

This commit is contained in:
2025-03-20 22:56:32 +01:00
parent d147d6602d
commit bb110646db
10 changed files with 43 additions and 30 deletions

View File

@ -539,7 +539,7 @@ word_wrap <- function(...,
)
# text starting with `?` must also lead to the help page
parts[parts %like% "^[?]"] <- font_url(
url = paste0("ide:help:AMR::", parts[parts %like% "^[?]"]),
url = paste0("ide:help:AMR::", gsub("?", "", parts[parts %like% "^[?]"], fixed = TRUE)),
txt = parts[parts %like% "^[?]"]
)
msg <- paste0(parts, collapse = "`")

10
R/ab.R
View File

@ -610,6 +610,16 @@ rep.ab <- function(x, ...) {
y
}
#' @method + ab
#' @export
#' @noRd
`+.ab` <- function(e1, e2) {
# this does not return ab class, it should just allow console usage of e.g., carbapenems() + c("", aminoglycosides())
out <- as.character(outer(e1, e2, paste, sep = " + "))
out <- gsub(" [+] $", "", out)
out
}
generalise_antibiotic_name <- function(x) {
x <- toupper(x)
# remove suffices

View File

@ -954,9 +954,10 @@ any.amr_selector_any_all <- function(..., na.rm = FALSE) {
#' @noRd
`+.amr_selector` <- function(e1, e2) {
# this is useful for `antibiogram()`: antibiogram(example_isolates, carbapenems() + c("", "GEN", "TOB"))
structure(as.character(outer(e1, e2, paste, sep = " + ")),
class = c("amr_selector", "character")
)
# this is also implemented for ab class, to allow direct console usage
out <- as.character(outer(e1, e2, paste, sep = " + "))
out <- gsub(" [+] $", "", out)
structure(out, class = c("amr_selector", "character"))
}
is_any <- function(el1) {

View File

@ -42,8 +42,9 @@
#' - `c(aminoglycosides(), "AMP", "AMC")`
#' - `c(aminoglycosides(), carbapenems())`
#' - Combination therapy, indicated by using `"+"`, with or without [antimicrobial selectors][antimicrobial_selectors], e.g.:
#' - `"TZP+TOB"`
#' - `"cipro + genta"`
#' - `"TZP+TOB"`
#' - `c("TZP", "TZP+GEN", "TZP+TOB")`
#' - `carbapenems() + "GEN"`
#' - `carbapenems() + c("", "GEN")`
#' - `carbapenems() + c("", aminoglycosides())`