1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 17:26:12 +01:00

algorithm improvement

This commit is contained in:
dr. M.S. (Matthijs) Berends 2023-01-07 14:53:14 +01:00
parent 08fe5a88c0
commit 1029aa2fdc
5 changed files with 27 additions and 19 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 1.8.2.9088 Version: 1.8.2.9089
Date: 2023-01-07 Date: 2023-01-07
Title: Antimicrobial Resistance Data Analysis Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR) Description: Functions to simplify and standardise antimicrobial resistance (AMR)

View File

@ -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!)* *(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)*

10
R/mo.R
View File

@ -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% translate_into_language("no .*growth", language = language)] <- NA_character_
x[trimws2(x) %like% paste0("^(", translate_into_language("no|not", 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 # run over all unique leftovers
x_unique <- unique(x[is.na(out) & !is.na(x)]) x_unique <- unique(x[is.na(out) & !is.na(x)])
@ -782,7 +785,7 @@ rep.mo <- function(x, ...) {
#' @noRd #' @noRd
print.mo_uncertainties <- function(x, ...) { print.mo_uncertainties <- function(x, ...) {
if (NROW(x) == 0) { 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)) return(invisible(NULL))
} }
@ -925,6 +928,11 @@ convert_colloquial_input <- function(x) {
x[x %like_case% "strepto[ck]o[ck].* [abcdfghkl]$"], x[x %like_case% "strepto[ck]o[ck].* [abcdfghkl]$"],
perl = TRUE 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].*", out[x %like_case% "group [abcdfghkl] strepto[ck]o[ck]"] <- gsub(".*group ([abcdfghkl]) strepto[ck]o[ck].*",
"B_STRPT_GRP\\U\\1", "B_STRPT_GRP\\U\\1",
x[x %like_case% "group [abcdfghkl] strepto[ck]o[ck]"], x[x %like_case% "group [abcdfghkl] strepto[ck]o[ck]"],

View File

@ -137,18 +137,18 @@
#' \donttest{ #' \donttest{
#' # Becker classification, see ?as.mo ---------------------------------------- #' # Becker classification, see ?as.mo ----------------------------------------
#' #'
#' mo_fullname("Staph. epidermidis") #' mo_fullname("Staph epidermidis")
#' mo_fullname("Staph. epidermidis", Becker = TRUE) #' mo_fullname("Staph epidermidis", Becker = TRUE)
#' mo_shortname("Staph. epidermidis") #' mo_shortname("Staph epidermidis")
#' mo_shortname("Staph. epidermidis", Becker = TRUE) #' mo_shortname("Staph epidermidis", Becker = TRUE)
#' #'
#' #'
#' # Lancefield classification, see ?as.mo ------------------------------------ #' # Lancefield classification, see ?as.mo ------------------------------------
#' #'
#' mo_fullname("Strep Group B") #' mo_fullname("Strep agalactiae")
#' mo_fullname("Strep Group B", Lancefield = TRUE) #' mo_fullname("Strep agalactiae", Lancefield = TRUE)
#' mo_shortname("Strep Group B") #' mo_shortname("Strep agalactiae")
#' mo_shortname("Strep Group B", Lancefield = TRUE) #' mo_shortname("Strep agalactiae", Lancefield = TRUE)
#' #'
#' #'
#' # language support -------------------------------------------------------- #' # language support --------------------------------------------------------

View File

@ -409,18 +409,18 @@ mo_shortname("K. pneu rh")
\donttest{ \donttest{
# Becker classification, see ?as.mo ---------------------------------------- # Becker classification, see ?as.mo ----------------------------------------
mo_fullname("Staph. epidermidis") mo_fullname("Staph epidermidis")
mo_fullname("Staph. epidermidis", Becker = TRUE) mo_fullname("Staph epidermidis", Becker = TRUE)
mo_shortname("Staph. epidermidis") mo_shortname("Staph epidermidis")
mo_shortname("Staph. epidermidis", Becker = TRUE) mo_shortname("Staph epidermidis", Becker = TRUE)
# Lancefield classification, see ?as.mo ------------------------------------ # Lancefield classification, see ?as.mo ------------------------------------
mo_fullname("Strep Group B") mo_fullname("Strep agalactiae")
mo_fullname("Strep Group B", Lancefield = TRUE) mo_fullname("Strep agalactiae", Lancefield = TRUE)
mo_shortname("Strep Group B") mo_shortname("Strep agalactiae")
mo_shortname("Strep Group B", Lancefield = TRUE) mo_shortname("Strep agalactiae", Lancefield = TRUE)
# language support -------------------------------------------------------- # language support --------------------------------------------------------