mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 22:41:52 +02:00
(v0.7.1.9004) atc class removal
This commit is contained in:
@ -48,14 +48,6 @@ test_that("as.ab works", {
|
||||
|
||||
expect_identical(class(pull(antibiotics, ab)), "ab")
|
||||
|
||||
# first 5 chars of official name
|
||||
expect_equal(as.character(as.atc(c("nitro", "cipro"))),
|
||||
c("J01XE01", "J01MA02"))
|
||||
|
||||
# EARS-Net
|
||||
expect_equal(as.character(as.atc("AMX")),
|
||||
"J01CA04")
|
||||
|
||||
expect_equal(as.character(as.ab("Phloxapen")),
|
||||
"FLC")
|
||||
|
||||
|
@ -1,39 +0,0 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Analysis #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://gitlab.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) #
|
||||
# #
|
||||
# This R package is free software; you can freely use and distribute #
|
||||
# it for both personal and commercial purposes under the terms of the #
|
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
||||
# the Free Software Foundation. #
|
||||
# #
|
||||
# This R package was created for academic research and was publicly #
|
||||
# released in the hope that it will be useful, but it comes WITHOUT #
|
||||
# ANY WARRANTY OR LIABILITY. #
|
||||
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
|
||||
# ==================================================================== #
|
||||
|
||||
context("ab.R")
|
||||
|
||||
test_that("as.atc works", {
|
||||
expect_identical(class(as.atc("amox")), "atc")
|
||||
expect_true(is.atc(as.atc("amox")))
|
||||
expect_output(print(as.atc("amox")))
|
||||
expect_output(print(data.frame(a = as.atc("amox"))))
|
||||
|
||||
expect_identical(class(pull(antibiotics, atc)), "atc")
|
||||
|
||||
expect_warning(as.atc("Z00ZZ00")) # not yet availatcle in data set
|
||||
expect_warning(as.atc("UNKNOWN"))
|
||||
|
||||
expect_output(print(as.atc("amox")))
|
||||
|
||||
|
||||
|
||||
})
|
@ -23,18 +23,16 @@ context("deprecated.R")
|
||||
|
||||
test_that("deprecated functions work", {
|
||||
|
||||
expect_error(suppressWarnings(ratio("A")))
|
||||
expect_error(suppressWarnings(ratio(1, ratio = "abc")))
|
||||
expect_error(suppressWarnings(ratio(c(1, 2), ratio = c(1, 2, 3))))
|
||||
expect_warning(ratio(c(772, 1611, 737), ratio = "1:2:1"))
|
||||
expect_identical(suppressWarnings(ratio(c(772, 1611, 737), ratio = "1:2:1")), c(780, 1560, 780))
|
||||
expect_identical(suppressWarnings(ratio(c(1752, 1895), ratio = c(1, 1))), c(1823.5, 1823.5))
|
||||
# first 5 chars of official name
|
||||
expect_equal(suppressWarnings(as.character(as.atc(c("nitro", "cipro")))),
|
||||
c("J01XE01", "J01MA02"))
|
||||
|
||||
expect_warning(atc_property("amox"))
|
||||
expect_warning(atc_official("amox"))
|
||||
expect_warning(ab_official("amox"))
|
||||
expect_warning(atc_name("amox"))
|
||||
expect_warning(atc_trivial_nl("amox"))
|
||||
expect_warning(atc_tradenames("amox"))
|
||||
# EARS-Net
|
||||
expect_equal(suppressWarnings(as.character(as.atc("AMX"))),
|
||||
"J01CA04")
|
||||
|
||||
expect_equal(suppressWarnings(guess_ab_col(data.frame(AMP_ND10 = "R",
|
||||
AMC_ED20 = "S"),
|
||||
as.atc("augmentin"))),
|
||||
"AMC_ED20")
|
||||
})
|
||||
|
@ -36,32 +36,31 @@ test_that("ggplot_rsi works", {
|
||||
summarise_all(portion_IR) %>% as.double()
|
||||
)
|
||||
|
||||
print(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))
|
||||
print(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))
|
||||
|
||||
expect_equal(
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "Interpretation", facet = "Antibiotic"))$data %>%
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))$data %>%
|
||||
summarise_all(portion_IR) %>% as.double(),
|
||||
septic_patients %>% select(AMC, CIP) %>%
|
||||
summarise_all(portion_IR) %>% as.double()
|
||||
)
|
||||
|
||||
expect_equal(
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "Antibiotic", facet = "Interpretation"))$data %>%
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))$data %>%
|
||||
summarise_all(portion_IR) %>% as.double(),
|
||||
septic_patients %>% select(AMC, CIP) %>%
|
||||
summarise_all(portion_IR) %>% as.double()
|
||||
)
|
||||
|
||||
expect_equal(
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "Antibiotic",
|
||||
facet = "Interpretation",
|
||||
fun = count_df))$data %>%
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic",
|
||||
facet = "interpretation"))$data %>%
|
||||
summarise_all(count_IR) %>% as.double(),
|
||||
septic_patients %>% select(AMC, CIP) %>%
|
||||
summarise_all(count_IR) %>% as.double()
|
||||
)
|
||||
|
||||
expect_error(ggplot_rsi(septic_patients, fun = "invalid"))
|
||||
expect_error(geom_rsi(septic_patients, fun = "invalid"))
|
||||
|
||||
# support for scale_type ab and mo
|
||||
expect_equal(class((data.frame(mo = as.mo(c("e. coli", "s aureus")),
|
||||
n = c(40, 100)) %>%
|
||||
|
@ -40,6 +40,5 @@ test_that("guess_ab_col works", {
|
||||
"AMP_ND10")
|
||||
expect_equal(guess_ab_col(df, "J01CR02"),
|
||||
"AMC_ED20")
|
||||
expect_equal(guess_ab_col(df, as.atc("augmentin")),
|
||||
"AMC_ED20")
|
||||
|
||||
})
|
||||
|
Reference in New Issue
Block a user