From 1029aa2fdc25962908c997929c1e611e3fbf2e1d Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Sat, 7 Jan 2023 14:53:14 +0100 Subject: [PATCH] algorithm improvement --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/mo.R | 10 +++++++++- R/mo_property.R | 16 ++++++++-------- man/mo_property.Rd | 16 ++++++++-------- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d091855e..2dc0e60e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.8.2.9088 +Version: 1.8.2.9089 Date: 2023-01-07 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 436c3797..e943c346 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9088 +# AMR 1.8.2.9089 *(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)* diff --git a/R/mo.R b/R/mo.R index 35f6a516..27d6982c 100755 --- a/R/mo.R +++ b/R/mo.R @@ -236,6 +236,9 @@ as.mo <- function(x, x[trimws2(x) %like% translate_into_language("no .*growth", language = language)] <- NA_character_ x[trimws2(x) %like% paste0("^(", translate_into_language("no|not", language = language), ") ")] <- NA_character_ + # groups are in our taxonomic table with a capital G + x <- gsub(" group ", " Group ", x, fixed = TRUE) + # run over all unique leftovers x_unique <- unique(x[is.na(out) & !is.na(x)]) @@ -782,7 +785,7 @@ rep.mo <- function(x, ...) { #' @noRd print.mo_uncertainties <- function(x, ...) { if (NROW(x) == 0) { - cat(word_wrap("No uncertainties to show. Only uncertainties of the last call of `as.mo()` or any `mo_*()` function are stored.\n", add_fn = font_blue)) + cat(word_wrap("No uncertainties to show. Only uncertainties of the last call of `as.mo()` or any `mo_*()` function are stored.\n\n", add_fn = font_blue)) return(invisible(NULL)) } @@ -925,6 +928,11 @@ convert_colloquial_input <- function(x) { x[x %like_case% "strepto[ck]o[ck].* [abcdfghkl]$"], perl = TRUE ) + out[x %like_case% "strep[a-z]* group [abcdfghkl]$"] <- gsub(".* ([abcdfghkl])$", + "B_STRPT_GRP\\U\\1", + x[x %like_case% "strep[a-z]* group [abcdfghkl]$"], + perl = TRUE + ) out[x %like_case% "group [abcdfghkl] strepto[ck]o[ck]"] <- gsub(".*group ([abcdfghkl]) strepto[ck]o[ck].*", "B_STRPT_GRP\\U\\1", x[x %like_case% "group [abcdfghkl] strepto[ck]o[ck]"], diff --git a/R/mo_property.R b/R/mo_property.R index b6c0fce4..dca10b53 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -137,18 +137,18 @@ #' \donttest{ #' # Becker classification, see ?as.mo ---------------------------------------- #' -#' mo_fullname("Staph. epidermidis") -#' mo_fullname("Staph. epidermidis", Becker = TRUE) -#' mo_shortname("Staph. epidermidis") -#' mo_shortname("Staph. epidermidis", Becker = TRUE) +#' mo_fullname("Staph epidermidis") +#' mo_fullname("Staph epidermidis", Becker = TRUE) +#' mo_shortname("Staph epidermidis") +#' mo_shortname("Staph epidermidis", Becker = TRUE) #' #' #' # Lancefield classification, see ?as.mo ------------------------------------ #' -#' mo_fullname("Strep Group B") -#' mo_fullname("Strep Group B", Lancefield = TRUE) -#' mo_shortname("Strep Group B") -#' mo_shortname("Strep Group B", Lancefield = TRUE) +#' mo_fullname("Strep agalactiae") +#' mo_fullname("Strep agalactiae", Lancefield = TRUE) +#' mo_shortname("Strep agalactiae") +#' mo_shortname("Strep agalactiae", Lancefield = TRUE) #' #' #' # language support -------------------------------------------------------- diff --git a/man/mo_property.Rd b/man/mo_property.Rd index c7c40fd6..fb4c0993 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -409,18 +409,18 @@ mo_shortname("K. pneu rh") \donttest{ # Becker classification, see ?as.mo ---------------------------------------- -mo_fullname("Staph. epidermidis") -mo_fullname("Staph. epidermidis", Becker = TRUE) -mo_shortname("Staph. epidermidis") -mo_shortname("Staph. epidermidis", Becker = TRUE) +mo_fullname("Staph epidermidis") +mo_fullname("Staph epidermidis", Becker = TRUE) +mo_shortname("Staph epidermidis") +mo_shortname("Staph epidermidis", Becker = TRUE) # Lancefield classification, see ?as.mo ------------------------------------ -mo_fullname("Strep Group B") -mo_fullname("Strep Group B", Lancefield = TRUE) -mo_shortname("Strep Group B") -mo_shortname("Strep Group B", Lancefield = TRUE) +mo_fullname("Strep agalactiae") +mo_fullname("Strep agalactiae", Lancefield = TRUE) +mo_shortname("Strep agalactiae") +mo_shortname("Strep agalactiae", Lancefield = TRUE) # language support --------------------------------------------------------