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:
34
R/ab.R
34
R/ab.R
@ -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")
|
||||
|
Reference in New Issue
Block a user