mirror of
https://github.com/msberends/AMR.git
synced 2025-07-13 02:32:07 +02:00
(v2.1.1.9186) replace antibiotics
with antimicrobials
!
This commit is contained in:
@ -27,80 +27,82 @@
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
ab_reset_session()
|
||||
test_that("ab works", {
|
||||
ab_reset_session()
|
||||
|
||||
expect_equal(
|
||||
as.character(as.ab(c(
|
||||
"J01FA01",
|
||||
"J 01 FA 01",
|
||||
"Erythromycin",
|
||||
"eryt",
|
||||
"ERYT",
|
||||
"ERY",
|
||||
"erytromicine",
|
||||
"Erythrocin",
|
||||
"Romycin"
|
||||
))),
|
||||
rep("ERY", 9)
|
||||
)
|
||||
expect_equal(
|
||||
as.character(as.ab(c(
|
||||
"J01FA01",
|
||||
"J 01 FA 01",
|
||||
"Erythromycin",
|
||||
"eryt",
|
||||
"ERYT",
|
||||
"ERY",
|
||||
"erytromicine",
|
||||
"Erythrocin",
|
||||
"Romycin"
|
||||
))),
|
||||
rep("ERY", 9)
|
||||
)
|
||||
|
||||
expect_identical(class(as.ab("amox")), c("ab", "character"))
|
||||
expect_identical(class(antibiotics$ab), c("ab", "character"))
|
||||
expect_true(is.ab(as.ab("amox")))
|
||||
expect_stdout(print(as.ab("amox")))
|
||||
expect_stdout(print(data.frame(a = as.ab("amox"))))
|
||||
expect_identical(class(as.ab("amox")), c("ab", "character"))
|
||||
expect_identical(class(AMR::antimicrobials$ab), c("ab", "character"))
|
||||
expect_true(is.ab(as.ab("amox")))
|
||||
expect_output(print(as.ab("amox")))
|
||||
expect_output(print(data.frame(a = as.ab("amox"))))
|
||||
|
||||
expect_warning(as.ab("J00AA00")) # ATC not yet available in data set
|
||||
# expect_warning(as.ab("UNKNOWN"))
|
||||
expect_warning(as.ab("J00AA00")) # ATC not yet available in data set
|
||||
# expect_warning(as.ab("UNKNOWN"))
|
||||
|
||||
expect_stdout(print(as.ab("amox")))
|
||||
expect_output(print(as.ab("amox")))
|
||||
|
||||
expect_equal(
|
||||
as.character(as.ab("Phloxapen")),
|
||||
"FLC"
|
||||
)
|
||||
expect_equal(
|
||||
as.character(as.ab("Phloxapen")),
|
||||
"FLC"
|
||||
)
|
||||
|
||||
expect_equal(
|
||||
suppressWarnings(as.character(as.ab(c("Bacteria", "Bacterial")))),
|
||||
c(NA, "TMP")
|
||||
)
|
||||
expect_equal(
|
||||
suppressWarnings(as.character(as.ab(c("Bacteria", "Bacterial")))),
|
||||
c(NA, "TMP")
|
||||
)
|
||||
|
||||
expect_equal(
|
||||
as.character(as.ab("Amoxy + clavulaanzuur")),
|
||||
"AMC"
|
||||
)
|
||||
expect_equal(
|
||||
as.character(as.ab("Amoxy + clavulaanzuur")),
|
||||
"AMC"
|
||||
)
|
||||
|
||||
expect_equal(
|
||||
as.character(as.ab(c("mreopenem", "co-maoxiclav"))),
|
||||
c("MEM", "AMC")
|
||||
)
|
||||
expect_equal(
|
||||
as.character(as.ab(c("mreopenem", "co-maoxiclav"))),
|
||||
c("MEM", "AMC")
|
||||
)
|
||||
|
||||
# expect_warning(as.ab("cipro mero"))
|
||||
# expect_warning(as.ab("cipro mero"))
|
||||
|
||||
# based on Levenshtein distance
|
||||
expect_identical(ab_name("ceftazidim/avibactam", language = NULL), "Ceftazidime/avibactam")
|
||||
# based on Levenshtein distance
|
||||
expect_identical(ab_name("ceftazidim/avibactam", language = NULL), "Ceftazidime/avibactam")
|
||||
|
||||
expect_identical(
|
||||
as.character(as.ab(c(
|
||||
"gentamicine High Level",
|
||||
"gentamicine High",
|
||||
"gentamicine (High Level)",
|
||||
"gentamicine (High)",
|
||||
"gentamicine HL",
|
||||
"gentamicine H-L",
|
||||
"gentamicine (HL)",
|
||||
"gentamicine (H-L)"
|
||||
))),
|
||||
rep("GEH", 8)
|
||||
)
|
||||
expect_identical(
|
||||
as.character(as.ab(c(
|
||||
"gentamicine High Level",
|
||||
"gentamicine High",
|
||||
"gentamicine (High Level)",
|
||||
"gentamicine (High)",
|
||||
"gentamicine HL",
|
||||
"gentamicine H-L",
|
||||
"gentamicine (HL)",
|
||||
"gentamicine (H-L)"
|
||||
))),
|
||||
rep("GEH", 8)
|
||||
)
|
||||
|
||||
# assigning and subsetting
|
||||
x <- antibiotics$ab
|
||||
expect_inherits(x[1], "ab")
|
||||
expect_inherits(x[[1]], "ab")
|
||||
expect_inherits(c(x[1], x[9]), "ab")
|
||||
expect_inherits(unique(x[1], x[9]), "ab")
|
||||
expect_inherits(rep(x[1], 2), "ab")
|
||||
# expect_warning(x[1] <- "invalid code")
|
||||
# expect_warning(x[[1]] <- "invalid code")
|
||||
# expect_warning(c(x[1], "test"))
|
||||
# assigning and subsetting
|
||||
x <- AMR::antimicrobials$ab
|
||||
expect_inherits(x[1], "ab")
|
||||
expect_inherits(x[[1]], "ab")
|
||||
expect_inherits(c(x[1], x[9]), "ab")
|
||||
expect_inherits(unique(x[1], x[9]), "ab")
|
||||
expect_inherits(rep(x[1], 2), "ab")
|
||||
# expect_warning(x[1] <- "invalid code")
|
||||
# expect_warning(x[[1]] <- "invalid code")
|
||||
# expect_warning(c(x[1], "test"))
|
||||
})
|
||||
|
Reference in New Issue
Block a user