mirror of https://github.com/msberends/AMR.git
(v2.1.1.9061) animal host fix
This commit is contained in:
parent
c67d003e9e
commit
82585901a7
|
@ -1,5 +1,5 @@
|
|||
Package: AMR
|
||||
Version: 2.1.1.9060
|
||||
Version: 2.1.1.9061
|
||||
Date: 2024-06-19
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
|
|
2
NEWS.md
2
NEWS.md
|
@ -1,4 +1,4 @@
|
|||
# AMR 2.1.1.9060
|
||||
# AMR 2.1.1.9061
|
||||
|
||||
*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)*
|
||||
|
||||
|
|
13
R/sir.R
13
R/sir.R
|
@ -832,7 +832,7 @@ get_guideline <- function(guideline, reference_data) {
|
|||
}
|
||||
|
||||
convert_host <- function(x, lang = get_AMR_locale()) {
|
||||
x <- trimws2(tolower(as.character(x)))
|
||||
x <- gsub("[^a-zA-Z ]", "", trimws2(tolower(as.character(x))), perl = TRUE)
|
||||
x_out <- rep(NA_character_, length(x))
|
||||
x_out[trimws2(tolower(x)) == "human"] <- "human"
|
||||
x_out[trimws2(tolower(x)) == "ecoff"] <- "ecoff"
|
||||
|
@ -860,8 +860,15 @@ convert_host <- function(x, lang = get_AMR_locale()) {
|
|||
x_out[is.na(x_out) & (x %like% "sheep|ovine" | x %like% translate_AMR("sheep|sheeps|ovine", lang))] <- "sheep"
|
||||
x_out[is.na(x_out) & (x %like% "snake|serpentine" | x %like% translate_AMR("snake|snakes|serpentine", lang))] <- "snakes"
|
||||
x_out[is.na(x_out) & (x %like% "turkey|meleagrine" | x %like% translate_AMR("turkey|turkeys|meleagrine", lang))] <- "turkey"
|
||||
if (message_not_thrown_before("convert_host", x) && any(is.na(x_out) & !is.na(x))) {
|
||||
warning_("The following host(s) are invalid: ", vector_and(x[is.na(x_out) & !is.na(x)]), call = FALSE, immediate = TRUE)
|
||||
if (any(x_out %in% c(NA_character_, "animal"))) {
|
||||
x_out[is.na(x_out) & x == "animal"] <- AMR_env$host_preferred_order[1]
|
||||
if (message_not_thrown_before("as.sir", "convert_host_missing")) {
|
||||
message_(ifelse(any(is.na(x_out) & !is.na(x), na.rm = TRUE),
|
||||
paste0("The following host(s) are invalid: ", vector_and(x[is.na(x_out) & !is.na(x)]), ". "),
|
||||
""),
|
||||
"For missing animal hosts, assuming \"", AMR_env$host_preferred_order[1], "\", since these have the highest breakpoint availability.")
|
||||
x_out[is.na(x_out)] <- AMR_env$host_preferred_order[1]
|
||||
}
|
||||
}
|
||||
x_out[x_out == "ecoff"] <- "ECOFF"
|
||||
x_out
|
||||
|
|
|
@ -36,7 +36,7 @@ expect_identical(
|
|||
c("EUCAST", "CLSI")
|
||||
)
|
||||
# no missing SDDs
|
||||
expect_identical(sum(is.na(AMR::clinical_breakpoints$is_SDD)), 0)
|
||||
expect_identical(sum(is.na(AMR::clinical_breakpoints$is_SDD)), 0L)
|
||||
|
||||
expect_true(as.sir("S") < as.sir("I"))
|
||||
expect_true(as.sir("I") < as.sir("R"))
|
||||
|
|
Loading…
Reference in New Issue