mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 04:46:11 +01:00
coercion fixes
This commit is contained in:
parent
3fc39198d0
commit
f203928f7e
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.8.2.9020
|
Version: 1.8.2.9021
|
||||||
Date: 2022-10-18
|
Date: 2022-10-19
|
||||||
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)
|
||||||
data analysis and to work with microbial and antimicrobial properties by
|
data analysis and to work with microbial and antimicrobial properties by
|
||||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
|||||||
# AMR 1.8.2.9020
|
# AMR 1.8.2.9021
|
||||||
|
|
||||||
This version will eventually become v2.0! We're happy to reach a new major milestone soon!
|
This version will eventually become v2.0! We're happy to reach a new major milestone soon!
|
||||||
|
|
||||||
|
2
R/mo.R
2
R/mo.R
@ -440,7 +440,7 @@ as.mo <- function(x,
|
|||||||
|
|
||||||
# All unknowns ----
|
# All unknowns ----
|
||||||
out[is.na(out) & !is.na(x)] <- "UNKNOWN"
|
out[is.na(out) & !is.na(x)] <- "UNKNOWN"
|
||||||
AMR_env$mo_failures <- unique(x[out == "UNKNOWN" & x != "UNKNOWN" & !is.na(x)])
|
AMR_env$mo_failures <- unique(x[out == "UNKNOWN" & !x %in% c("UNKNOWN", "con") & !x %like_case% "^[(]unknown [a-z]+[)]$" & !is.na(x)])
|
||||||
if (length(AMR_env$mo_failures) > 0) {
|
if (length(AMR_env$mo_failures) > 0) {
|
||||||
warning_("The following input could not be coerced and was returned as \"UNKNOWN\": ", vector_and(AMR_env$mo_failures, quotes = TRUE), ".\nYou can retrieve this list with `mo_failures()`.")
|
warning_("The following input could not be coerced and was returned as \"UNKNOWN\": ", vector_and(AMR_env$mo_failures, quotes = TRUE), ".\nYou can retrieve this list with `mo_failures()`.")
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ expect_stdout(print(data.frame(a = as.ab("amox"))))
|
|||||||
|
|
||||||
expect_warning(as.ab("J00AA00")) # ATC not yet available in data set
|
expect_warning(as.ab("J00AA00")) # ATC not yet available in data set
|
||||||
expect_warning(as.ab("UNKNOWN"))
|
expect_warning(as.ab("UNKNOWN"))
|
||||||
expect_warning(as.ab(""))
|
|
||||||
|
|
||||||
expect_stdout(print(as.ab("amox")))
|
expect_stdout(print(as.ab("amox")))
|
||||||
|
|
||||||
@ -75,7 +74,7 @@ expect_equal(
|
|||||||
c("MEM", "AMC")
|
c("MEM", "AMC")
|
||||||
)
|
)
|
||||||
|
|
||||||
expect_message(as.ab("cipro mero"))
|
expect_warning(as.ab("cipro mero"))
|
||||||
|
|
||||||
# based on Levenshtein distance
|
# based on Levenshtein distance
|
||||||
expect_identical(ab_name("ceftazidim/avibactam", language = NULL), "Ceftazidime/avibactam")
|
expect_identical(ab_name("ceftazidim/avibactam", language = NULL), "Ceftazidime/avibactam")
|
||||||
@ -86,6 +85,7 @@ expect_inherits(x[1], "ab")
|
|||||||
expect_inherits(x[[1]], "ab")
|
expect_inherits(x[[1]], "ab")
|
||||||
expect_inherits(c(x[1], x[9]), "ab")
|
expect_inherits(c(x[1], x[9]), "ab")
|
||||||
expect_inherits(unique(x[1], x[9]), "ab")
|
expect_inherits(unique(x[1], x[9]), "ab")
|
||||||
|
expect_inherits(rep(x[1], x[9]), "ab")
|
||||||
expect_warning(x[1] <- "invalid code")
|
expect_warning(x[1] <- "invalid code")
|
||||||
expect_warning(x[[1]] <- "invalid code")
|
expect_warning(x[[1]] <- "invalid code")
|
||||||
expect_warning(c(x[1], "test"))
|
expect_warning(c(x[1], "test"))
|
||||||
|
@ -283,7 +283,7 @@ expect_equal(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# no viruses
|
# no viruses
|
||||||
expect_equal(as.mo("Virus"), as.mo("UNKNOWN"))
|
expect_equal(suppressWarnings(as.mo("Virus")), as.mo("UNKNOWN"))
|
||||||
|
|
||||||
# summary
|
# summary
|
||||||
expect_equal(length(summary(example_isolates$mo)), 6)
|
expect_equal(length(summary(example_isolates$mo)), 6)
|
||||||
|
Loading…
Reference in New Issue
Block a user