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

(v1.5.0.9039) handle first isolates for missing antibiograms

This commit is contained in:
2021-03-08 02:38:32 +01:00
parent 461793dc34
commit a7c9b4c295
21 changed files with 79 additions and 62 deletions

34
R/ab.R
View File

@ -109,23 +109,23 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
x <- toupper(x)
x_nonNA <- x[!is.na(x)]
# if (all(x_nonNA %in% antibiotics$ab, na.rm = TRUE)) {
# # all valid AB codes, but not yet right class
# return(set_clean_class(x,
# new_class = c("ab", "character")))
# }
# if (all(x_nonNA %in% toupper(antibiotics$name), na.rm = TRUE)) {
# # all valid AB names
# out <- antibiotics$ab[match(x, toupper(antibiotics$name))]
# out[is.na(x)] <- NA_character_
# return(out)
# }
# if (all(x_nonNA %in% antibiotics$atc, na.rm = TRUE)) {
# # all valid ATC codes
# out <- antibiotics$ab[match(x, antibiotics$atc)]
# out[is.na(x)] <- NA_character_
# return(out)
# }
if (all(x_nonNA %in% antibiotics$ab, na.rm = TRUE)) {
# all valid AB codes, but not yet right class
return(set_clean_class(x,
new_class = c("ab", "character")))
}
if (all(x_nonNA %in% toupper(antibiotics$name), na.rm = TRUE)) {
# all valid AB names
out <- antibiotics$ab[match(x, toupper(antibiotics$name))]
out[is.na(x)] <- NA_character_
return(out)
}
if (all(x_nonNA %in% antibiotics$atc, na.rm = TRUE)) {
# all valid ATC codes
out <- antibiotics$ab[match(x, antibiotics$atc)]
out[is.na(x)] <- NA_character_
return(out)
}
# remove diacritics
x <- iconv(x, from = "UTF-8", to = "ASCII//TRANSLIT")