diff --git a/DESCRIPTION b/DESCRIPTION index 80c08bec8..2956cad60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 3.0.1.9016 +Version: 3.0.1.9017 Date: 2026-01-08 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index d5050c1fa..54c901a67 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 3.0.1.9016 +# AMR 3.0.1.9017 ### New * Integration with the **tidymodels** framework to allow seamless use of SIR, MIC and disk data in modelling pipelines via `recipes` diff --git a/R/ab_property.R b/R/ab_property.R index 8700f086f..5058a96aa 100755 --- a/R/ab_property.R +++ b/R/ab_property.R @@ -163,6 +163,7 @@ ab_tradenames <- function(x, ...) { } #' @rdname ab_property +#' @param all_groups A [logical] to indicate whether all antimicrobial groups must be return as a vector for each input value. For example, an antibiotic in the "aminopenicillins" group, is also in the "penicillins" and "beta-lactams" groups. Setting `all_groups = TRUE` would return all three for such an antibiotic, while `all_groups = FALSE` (default) only returns the most distinctive group name. #' @export ab_group <- function(x, language = get_AMR_locale(), all_groups = FALSE, ...) { meet_criteria(x, allow_NA = TRUE) @@ -171,11 +172,9 @@ ab_group <- function(x, language = get_AMR_locale(), all_groups = FALSE, ...) { grps <- ab_validate(x = x, property = "group", ...) for (i in seq_along(grps)) { - # take the first match based on ABX_PRIORITY_LIST if (all_groups == FALSE) { + # take the first match based on ABX_PRIORITY_LIST grps[[i]] <- grps[[i]][1] - } else if (length(grps[[i]]) > 1) { - grps[[i]] <- grps[[i]][grps[[i]] != "Beta-lactamase inhibitors"] # leave these out if there are other groups } if (language != "en") { grps[[i]] <- translate_into_language(grps[[i]], language = language, only_affect_ab_names = TRUE) diff --git a/man/ab_property.Rd b/man/ab_property.Rd index 7673b7d41..188bf130e 100644 --- a/man/ab_property.Rd +++ b/man/ab_property.Rd @@ -59,6 +59,8 @@ set_ab_names(data, ..., property = "name", language = get_AMR_locale(), \item{...}{In case of \code{\link[=set_ab_names]{set_ab_names()}} and \code{data} is a \link{data.frame}: columns to select (supports tidy selection such as \code{column1:column4}), otherwise other arguments passed on to \code{\link[=as.ab]{as.ab()}}.} +\item{all_groups}{A \link{logical} to indicate whether all antimicrobial groups must be return as a vector for each input value. For example, an antibiotic in the "aminopenicillins" group, is also in the "penicillins" and "beta-lactams" groups. Setting \code{all_groups = TRUE} would return all three for such an antibiotic, while \code{all_groups = FALSE} (default) only returns the most distinctive group name.} + \item{only_first}{A \link{logical} to indicate whether only the first ATC code must be returned, with giving preference to J0-codes (i.e., the antimicrobial drug group).} \item{administration}{Way of administration, either \code{"oral"} or \code{"iv"}.} diff --git a/tests/testthat/test-ab_property.R b/tests/testthat/test-ab_property.R index 6198b22c0..a0505a34d 100644 --- a/tests/testthat/test-ab_property.R +++ b/tests/testthat/test-ab_property.R @@ -40,6 +40,7 @@ test_that("test-ab_property.R", { expect_inherits(ab_tradenames(c("AMX", "AMX")), "list") expect_identical(ab_group("AMX", language = NULL), "Aminopenicillins") + expect_identical(ab_group("AMX", language = NULL, all_groups = TRUE), c("Aminopenicillins", "Penicillins", "Beta-lactams")) expect_identical(ab_atc_group1("AMX", language = NULL), "Beta-lactam antibacterials, penicillins") expect_identical(ab_atc_group2("AMX", language = NULL), "Penicillins with extended spectrum")