1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 16:42:10 +02:00

(v1.2.0.9036) unit test fix

This commit is contained in:
2020-07-22 12:29:51 +02:00
parent 09fba38ea6
commit ab2b359e6b
13 changed files with 29 additions and 25 deletions

9
R/mo.R
View File

@ -178,7 +178,7 @@ as.mo <- function(x,
# start off with replaced language-specific non-ASCII characters with ASCII characters
x <- parse_and_convert(x)
# replace mo codes used in older package versions
x <- replace_old_mo_codes(x)
x <- replace_old_mo_codes(x, property = "mo")
# WHONET: xxx = no growth
x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_
@ -291,7 +291,7 @@ exec_as.mo <- function(x,
# start off with replaced language-specific non-ASCII characters with ASCII characters
x <- parse_and_convert(x)
# replace mo codes used in older package versions
x <- replace_old_mo_codes(x)
x <- replace_old_mo_codes(x, property)
# WHONET: xxx = no growth
x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_
@ -1782,7 +1782,7 @@ parse_and_convert <- function(x) {
parsed
}
replace_old_mo_codes <- function(x) {
replace_old_mo_codes <- function(x, property) {
if (any(toupper(x) %in% microorganisms.translation$mo_old, na.rm = TRUE)) {
# get the ones that match
matched <- match(toupper(x), microorganisms.translation$mo_old)
@ -1790,6 +1790,9 @@ replace_old_mo_codes <- function(x) {
mo_new <- microorganisms.translation$mo_new[matched]
# assign on places where a match was found
x[which(!is.na(matched))] <- mo_new[which(!is.na(matched))]
if (property != "mo") {
message(font_blue("NOTE: Old microbial codes (from previous package versions) were replaced with current codes used by this package.\n Please update your MO codes with as.mo()." ))
}
}
x
}