mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 09:11:51 +02:00
(v0.7.1.9063) septic_patients -> example_isolates
This commit is contained in:
@ -22,5 +22,5 @@
|
||||
context("availability.R")
|
||||
|
||||
test_that("availability works", {
|
||||
expect_equal(class(availability(septic_patients)), "data.frame")
|
||||
expect_equal(class(availability(example_isolates)), "data.frame")
|
||||
})
|
||||
|
@ -22,7 +22,7 @@
|
||||
context("bug_drug_combinations.R")
|
||||
|
||||
test_that("bug_drug_combinations works", {
|
||||
b <- suppressWarnings(bug_drug_combinations(septic_patients))
|
||||
b <- suppressWarnings(bug_drug_combinations(example_isolates))
|
||||
expect_s3_class(b, "bugdrug")
|
||||
expect_message(print(b))
|
||||
expect_true(is.data.frame(format(b)))
|
||||
|
@ -22,27 +22,27 @@
|
||||
context("count.R")
|
||||
|
||||
test_that("counts work", {
|
||||
# AMX resistance in `septic_patients`
|
||||
expect_equal(count_R(septic_patients$AMX), 683)
|
||||
expect_equal(count_I(septic_patients$AMX), 3)
|
||||
expect_equal(count_S(septic_patients$AMX), 543)
|
||||
expect_equal(count_R(septic_patients$AMX) + count_I(septic_patients$AMX),
|
||||
count_IR(septic_patients$AMX))
|
||||
expect_equal(count_S(septic_patients$AMX) + count_I(septic_patients$AMX),
|
||||
count_SI(septic_patients$AMX))
|
||||
# AMX resistance in `example_isolates`
|
||||
expect_equal(count_R(example_isolates$AMX), 683)
|
||||
expect_equal(count_I(example_isolates$AMX), 3)
|
||||
expect_equal(count_S(example_isolates$AMX), 543)
|
||||
expect_equal(count_R(example_isolates$AMX) + count_I(example_isolates$AMX),
|
||||
count_IR(example_isolates$AMX))
|
||||
expect_equal(count_S(example_isolates$AMX) + count_I(example_isolates$AMX),
|
||||
count_SI(example_isolates$AMX))
|
||||
|
||||
library(dplyr)
|
||||
expect_equal(septic_patients %>% count_S(AMC), 1342)
|
||||
expect_equal(septic_patients %>% count_S(AMC, GEN, only_all_tested = TRUE), 1660)
|
||||
expect_equal(septic_patients %>% count_S(AMC, GEN, only_all_tested = FALSE), 1728)
|
||||
expect_equal(septic_patients %>% count_all(AMC, GEN, only_all_tested = TRUE), 1798)
|
||||
expect_equal(septic_patients %>% count_all(AMC, GEN, only_all_tested = FALSE), 1936)
|
||||
expect_identical(septic_patients %>% count_all(AMC, GEN, only_all_tested = TRUE),
|
||||
septic_patients %>% count_S(AMC, GEN, only_all_tested = TRUE) +
|
||||
septic_patients %>% count_IR(AMC, GEN, only_all_tested = TRUE))
|
||||
expect_equal(example_isolates %>% count_S(AMC), 1342)
|
||||
expect_equal(example_isolates %>% count_S(AMC, GEN, only_all_tested = TRUE), 1660)
|
||||
expect_equal(example_isolates %>% count_S(AMC, GEN, only_all_tested = FALSE), 1728)
|
||||
expect_equal(example_isolates %>% count_all(AMC, GEN, only_all_tested = TRUE), 1798)
|
||||
expect_equal(example_isolates %>% count_all(AMC, GEN, only_all_tested = FALSE), 1936)
|
||||
expect_identical(example_isolates %>% count_all(AMC, GEN, only_all_tested = TRUE),
|
||||
example_isolates %>% count_S(AMC, GEN, only_all_tested = TRUE) +
|
||||
example_isolates %>% count_IR(AMC, GEN, only_all_tested = TRUE))
|
||||
|
||||
# count of cases
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
group_by(hospital_id) %>%
|
||||
summarise(cipro = count_SI(CIP),
|
||||
genta = count_SI(GEN),
|
||||
@ -52,29 +52,29 @@ test_that("counts work", {
|
||||
|
||||
# count_df
|
||||
expect_equal(
|
||||
septic_patients %>% select(AMX) %>% count_df() %>% pull(value),
|
||||
c(septic_patients$AMX %>% count_SI(),
|
||||
septic_patients$AMX %>% count_R())
|
||||
example_isolates %>% select(AMX) %>% count_df() %>% pull(value),
|
||||
c(example_isolates$AMX %>% count_SI(),
|
||||
example_isolates$AMX %>% count_R())
|
||||
)
|
||||
expect_equal(
|
||||
septic_patients %>% select(AMX) %>% count_df(combine_IR = TRUE) %>% pull(value),
|
||||
c(septic_patients$AMX %>% count_S(),
|
||||
septic_patients$AMX %>% count_IR())
|
||||
example_isolates %>% select(AMX) %>% count_df(combine_IR = TRUE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% count_S(),
|
||||
example_isolates$AMX %>% count_IR())
|
||||
)
|
||||
expect_equal(
|
||||
septic_patients %>% select(AMX) %>% count_df(combine_SI = FALSE) %>% pull(value),
|
||||
c(septic_patients$AMX %>% count_S(),
|
||||
septic_patients$AMX %>% count_I(),
|
||||
septic_patients$AMX %>% count_R())
|
||||
example_isolates %>% select(AMX) %>% count_df(combine_SI = FALSE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% count_S(),
|
||||
example_isolates$AMX %>% count_I(),
|
||||
example_isolates$AMX %>% count_R())
|
||||
)
|
||||
|
||||
# warning for speed loss
|
||||
expect_warning(count_R(as.character(septic_patients$AMC)))
|
||||
expect_warning(count_I(as.character(septic_patients$AMC)))
|
||||
expect_warning(count_S(as.character(septic_patients$AMC,
|
||||
septic_patients$GEN)))
|
||||
expect_warning(count_S(septic_patients$AMC,
|
||||
as.character(septic_patients$GEN)))
|
||||
expect_warning(count_R(as.character(example_isolates$AMC)))
|
||||
expect_warning(count_I(as.character(example_isolates$AMC)))
|
||||
expect_warning(count_S(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_warning(count_S(example_isolates$AMC,
|
||||
as.character(example_isolates$GEN)))
|
||||
|
||||
# check for errors
|
||||
expect_error(count_IR("test", minimum = "test"))
|
||||
@ -85,6 +85,6 @@ test_that("counts work", {
|
||||
expect_error(count_S("test", as_percent = "test"))
|
||||
|
||||
expect_error(count_df(c("A", "B", "C")))
|
||||
expect_error(count_df(septic_patients[,"date"]))
|
||||
expect_error(count_df(example_isolates[,"date"]))
|
||||
|
||||
})
|
||||
|
@ -30,15 +30,15 @@ test_that("EUCAST rules work", {
|
||||
"then_change_these_antibiotics", "to_value",
|
||||
"reference.rule", "reference.rule_group"))
|
||||
|
||||
expect_error(suppressWarnings(eucast_rules(septic_patients, col_mo = "Non-existing")))
|
||||
expect_error(suppressWarnings(eucast_rules(example_isolates, col_mo = "Non-existing")))
|
||||
expect_error(eucast_rules(x = "text"))
|
||||
expect_error(eucast_rules(data.frame(a = "test")))
|
||||
expect_error(eucast_rules(data.frame(mo = "test"), rules = "invalid rules set"))
|
||||
|
||||
expect_warning(eucast_rules(data.frame(mo = "Escherichia coli", vancomycin = "S")))
|
||||
|
||||
expect_identical(colnames(septic_patients),
|
||||
colnames(suppressWarnings(eucast_rules(septic_patients))))
|
||||
expect_identical(colnames(example_isolates),
|
||||
colnames(suppressWarnings(eucast_rules(example_isolates))))
|
||||
|
||||
a <- data.frame(mo = c("Klebsiella pneumoniae",
|
||||
"Pseudomonas aeruginosa",
|
||||
@ -66,7 +66,7 @@ test_that("EUCAST rules work", {
|
||||
# piperacillin must be R in Enterobacteriaceae when tica is R
|
||||
library(dplyr)
|
||||
expect_equal(suppressWarnings(
|
||||
septic_patients %>%
|
||||
example_isolates %>%
|
||||
mutate(TIC = as.rsi("R"),
|
||||
PIP = as.rsi("S")) %>%
|
||||
eucast_rules(col_mo = "mo") %>%
|
||||
@ -79,7 +79,7 @@ test_that("EUCAST rules work", {
|
||||
|
||||
# Azithromicin and Clarythromycin must be equal to Erythromycin
|
||||
a <- suppressWarnings(
|
||||
septic_patients %>%
|
||||
example_isolates %>%
|
||||
transmute(mo,
|
||||
ERY,
|
||||
AZM = as.rsi("R"),
|
||||
@ -87,7 +87,7 @@ test_that("EUCAST rules work", {
|
||||
eucast_rules(col_mo = "mo") %>%
|
||||
pull(CLR))
|
||||
b <- suppressWarnings(
|
||||
septic_patients %>%
|
||||
example_isolates %>%
|
||||
select(mo, ERY) %>%
|
||||
eucast_rules(col_mo = "mo") %>%
|
||||
pull(ERY))
|
||||
@ -108,9 +108,9 @@ test_that("EUCAST rules work", {
|
||||
"S")
|
||||
|
||||
# also test norf
|
||||
expect_output(suppressWarnings(eucast_rules(septic_patients %>% mutate(NOR = "S", NAL = "S"))))
|
||||
expect_output(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S"))))
|
||||
|
||||
# check verbose output
|
||||
expect_output(suppressWarnings(eucast_rules(septic_patients, verbose = TRUE)))
|
||||
expect_output(suppressWarnings(eucast_rules(example_isolates, verbose = TRUE)))
|
||||
|
||||
})
|
||||
|
@ -23,22 +23,22 @@ context("filter_ab_class.R")
|
||||
|
||||
test_that("ATC-group filtering works", {
|
||||
library(dplyr)
|
||||
expect_gt(septic_patients %>% filter_ab_class("carbapenem") %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_aminoglycosides() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_carbapenems() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_1st_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_2nd_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_3rd_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_4th_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_fluoroquinolones() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_glycopeptides() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_macrolides() %>% nrow(), 0)
|
||||
expect_gt(septic_patients %>% filter_tetracyclines() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_ab_class("carbapenem") %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_aminoglycosides() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_carbapenems() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_1st_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_2nd_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_3rd_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_4th_cephalosporins() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_fluoroquinolones() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_glycopeptides() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_macrolides() %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_tetracyclines() %>% nrow(), 0)
|
||||
|
||||
expect_gt(septic_patients %>% filter_carbapenems("R", "all") %>% nrow(), 0)
|
||||
expect_gt(example_isolates %>% filter_carbapenems("R", "all") %>% nrow(), 0)
|
||||
|
||||
expect_error(septic_patients %>% filter_carbapenems(result = "test"))
|
||||
expect_error(septic_patients %>% filter_carbapenems(scope = "test"))
|
||||
expect_warning(septic_patients %>% select(1:3) %>% filter_carbapenems())
|
||||
expect_error(example_isolates %>% filter_carbapenems(result = "test"))
|
||||
expect_error(example_isolates %>% filter_carbapenems(scope = "test"))
|
||||
expect_warning(example_isolates %>% select(1:3) %>% filter_carbapenems())
|
||||
})
|
||||
|
@ -25,7 +25,7 @@ test_that("first isolates work", {
|
||||
# first isolates
|
||||
expect_equal(
|
||||
sum(
|
||||
first_isolate(x = septic_patients,
|
||||
first_isolate(x = example_isolates,
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_mo = "mo",
|
||||
@ -37,7 +37,7 @@ test_that("first isolates work", {
|
||||
expect_equal(
|
||||
suppressWarnings(
|
||||
sum(
|
||||
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = example_isolates %>% mutate(keyab = key_antibiotics(.)),
|
||||
# let syntax determine these automatically:
|
||||
# col_date = "date",
|
||||
# col_patient_id = "patient_id",
|
||||
@ -51,7 +51,7 @@ test_that("first isolates work", {
|
||||
expect_equal(
|
||||
suppressWarnings(
|
||||
sum(
|
||||
first_isolate(x = septic_patients %>% dplyr::as_tibble() %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = example_isolates %>% dplyr::as_tibble() %>% mutate(keyab = key_antibiotics(.)),
|
||||
# let syntax determine these automatically:
|
||||
# col_date = "date",
|
||||
# col_patient_id = "patient_id",
|
||||
@ -65,7 +65,7 @@ test_that("first isolates work", {
|
||||
expect_equal(
|
||||
suppressWarnings(
|
||||
sum(
|
||||
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = example_isolates %>% mutate(keyab = key_antibiotics(.)),
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_mo = "mo",
|
||||
@ -79,7 +79,7 @@ test_that("first isolates work", {
|
||||
expect_equal(
|
||||
suppressWarnings(
|
||||
sum(
|
||||
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = example_isolates %>% mutate(keyab = key_antibiotics(.)),
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_mo = "mo",
|
||||
@ -92,7 +92,7 @@ test_that("first isolates work", {
|
||||
# first non-ICU isolates
|
||||
expect_equal(
|
||||
sum(
|
||||
first_isolate(septic_patients,
|
||||
first_isolate(example_isolates,
|
||||
col_mo = "mo",
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
@ -106,7 +106,7 @@ test_that("first isolates work", {
|
||||
random_rows <- sample(x = 1:2000, size = 1500, replace = FALSE)
|
||||
expect_lt(
|
||||
sum(
|
||||
first_isolate(x = mutate(septic_patients,
|
||||
first_isolate(x = mutate(example_isolates,
|
||||
specimen = if_else(row_number() %in% random_rows,
|
||||
"Urine",
|
||||
"Other")),
|
||||
@ -121,7 +121,7 @@ test_that("first isolates work", {
|
||||
# same, but now exclude ICU
|
||||
expect_lt(
|
||||
sum(
|
||||
first_isolate(x = mutate(septic_patients,
|
||||
first_isolate(x = mutate(example_isolates,
|
||||
specimen = if_else(row_number() %in% random_rows,
|
||||
"Urine",
|
||||
"Other")),
|
||||
@ -137,7 +137,7 @@ test_that("first isolates work", {
|
||||
1501)
|
||||
|
||||
# "No isolates found"
|
||||
expect_message(septic_patients %>%
|
||||
expect_message(example_isolates %>%
|
||||
mutate(specimen = "test") %>%
|
||||
mutate(first = first_isolate(., "date", "patient_id",
|
||||
col_mo = "mo",
|
||||
@ -145,7 +145,7 @@ test_that("first isolates work", {
|
||||
filter_specimen = "something_unexisting")))
|
||||
|
||||
# printing of exclusion message
|
||||
expect_output(septic_patients %>%
|
||||
expect_output(example_isolates %>%
|
||||
first_isolate(col_date = "date",
|
||||
col_mo = "mo",
|
||||
col_patient_id = "patient_id",
|
||||
@ -154,29 +154,29 @@ test_that("first isolates work", {
|
||||
|
||||
# errors
|
||||
expect_error(first_isolate("date", "patient_id", col_mo = "mo"))
|
||||
expect_error(first_isolate(septic_patients,
|
||||
expect_error(first_isolate(example_isolates,
|
||||
col_date = "non-existing col",
|
||||
col_mo = "mo"))
|
||||
|
||||
# look for columns itself
|
||||
expect_message(first_isolate(septic_patients))
|
||||
expect_message(first_isolate(septic_patients %>%
|
||||
expect_message(first_isolate(example_isolates))
|
||||
expect_message(first_isolate(example_isolates %>%
|
||||
mutate(mo = as.character(mo)) %>%
|
||||
left_join_microorganisms()))
|
||||
|
||||
# if mo is not an mo class, result should be the same
|
||||
expect_identical(septic_patients %>%
|
||||
expect_identical(example_isolates %>%
|
||||
mutate(mo = as.character(mo)) %>%
|
||||
first_isolate(col_date = "date",
|
||||
col_mo = "mo",
|
||||
col_patient_id = "patient_id"),
|
||||
septic_patients %>%
|
||||
example_isolates %>%
|
||||
first_isolate(col_date = "date",
|
||||
col_mo = "mo",
|
||||
col_patient_id = "patient_id"))
|
||||
|
||||
# missing dates should be no problem
|
||||
df <- septic_patients
|
||||
df <- example_isolates
|
||||
df[1:100, "date"] <- NA
|
||||
expect_equal(
|
||||
sum(
|
||||
@ -189,19 +189,19 @@ test_that("first isolates work", {
|
||||
1322)
|
||||
|
||||
# unknown MOs
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COL", "UNKNOWN", mo)) %>%
|
||||
mutate(first = first_isolate(., include_unknown = FALSE)) %>%
|
||||
.$first %>%
|
||||
sum(),
|
||||
1062)
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COL", "UNKNOWN", mo)) %>%
|
||||
mutate(first = first_isolate(., include_unknown = TRUE)) %>%
|
||||
.$first %>%
|
||||
sum(),
|
||||
1529)
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COL", NA, mo)) %>%
|
||||
mutate(first = first_isolate(.)) %>%
|
||||
.$first %>%
|
||||
|
@ -24,10 +24,10 @@ context("freq.R")
|
||||
test_that("frequency table works", {
|
||||
library(clean)
|
||||
# mo
|
||||
expect_true(is.freq(freq(septic_patients$mo)))
|
||||
expect_true(is.freq(freq(example_isolates$mo)))
|
||||
# rsi
|
||||
expect_true(is.freq(freq(septic_patients$AMX)))
|
||||
expect_true(is.freq(freq(example_isolates$AMX)))
|
||||
library(dplyr)
|
||||
expect_true(is.freq(septic_patients %>% freq(mo)))
|
||||
expect_true(is.freq(example_isolates %>% freq(mo)))
|
||||
})
|
||||
|
||||
|
@ -30,34 +30,34 @@ test_that("ggplot_rsi works", {
|
||||
|
||||
# data should be equal
|
||||
expect_equal(
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi())$data %>%
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi())$data %>%
|
||||
summarise_all(portion_IR) %>% as.double(),
|
||||
septic_patients %>% select(AMC, CIP) %>%
|
||||
example_isolates %>% select(AMC, CIP) %>%
|
||||
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"))
|
||||
print(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))
|
||||
print(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))
|
||||
|
||||
expect_equal(
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))$data %>%
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))$data %>%
|
||||
summarise_all(portion_IR) %>% as.double(),
|
||||
septic_patients %>% select(AMC, CIP) %>%
|
||||
example_isolates %>% select(AMC, CIP) %>%
|
||||
summarise_all(portion_IR) %>% as.double()
|
||||
)
|
||||
|
||||
expect_equal(
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))$data %>%
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))$data %>%
|
||||
summarise_all(portion_IR) %>% as.double(),
|
||||
septic_patients %>% select(AMC, CIP) %>%
|
||||
example_isolates %>% select(AMC, CIP) %>%
|
||||
summarise_all(portion_IR) %>% as.double()
|
||||
)
|
||||
|
||||
expect_equal(
|
||||
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic",
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic",
|
||||
facet = "interpretation"))$data %>%
|
||||
summarise_all(count_IR) %>% as.double(),
|
||||
septic_patients %>% select(AMC, CIP) %>%
|
||||
example_isolates %>% select(AMC, CIP) %>%
|
||||
summarise_all(count_IR) %>% as.double()
|
||||
)
|
||||
|
||||
|
@ -23,15 +23,15 @@ context("guess_ab_col.R")
|
||||
|
||||
test_that("guess_ab_col works", {
|
||||
|
||||
expect_equal(guess_ab_col(septic_patients, "amox"),
|
||||
expect_equal(guess_ab_col(example_isolates, "amox"),
|
||||
"AMX")
|
||||
expect_equal(guess_ab_col(septic_patients, "amoxicillin"),
|
||||
expect_equal(guess_ab_col(example_isolates, "amoxicillin"),
|
||||
"AMX")
|
||||
expect_equal(guess_ab_col(septic_patients, "J01AA07"),
|
||||
expect_equal(guess_ab_col(example_isolates, "J01AA07"),
|
||||
"TCY")
|
||||
expect_equal(guess_ab_col(septic_patients, "tetracycline"),
|
||||
expect_equal(guess_ab_col(example_isolates, "tetracycline"),
|
||||
"TCY")
|
||||
expect_equal(guess_ab_col(septic_patients, "TETR"),
|
||||
expect_equal(guess_ab_col(example_isolates, "TETR"),
|
||||
"TCY")
|
||||
|
||||
df <- data.frame(AMP_ND10 = "R",
|
||||
|
@ -22,13 +22,13 @@
|
||||
context("join_microorganisms.R")
|
||||
|
||||
test_that("joins work", {
|
||||
unjoined <- septic_patients
|
||||
inner <- septic_patients %>% inner_join_microorganisms()
|
||||
left <- septic_patients %>% left_join_microorganisms()
|
||||
semi <- septic_patients %>% semi_join_microorganisms()
|
||||
anti <- septic_patients %>% anti_join_microorganisms()
|
||||
suppressWarnings(right <- septic_patients %>% right_join_microorganisms())
|
||||
suppressWarnings(full <- septic_patients %>% full_join_microorganisms())
|
||||
unjoined <- example_isolates
|
||||
inner <- example_isolates %>% inner_join_microorganisms()
|
||||
left <- example_isolates %>% left_join_microorganisms()
|
||||
semi <- example_isolates %>% semi_join_microorganisms()
|
||||
anti <- example_isolates %>% anti_join_microorganisms()
|
||||
suppressWarnings(right <- example_isolates %>% right_join_microorganisms())
|
||||
suppressWarnings(full <- example_isolates %>% full_join_microorganisms())
|
||||
|
||||
expect_true(ncol(unjoined) < ncol(inner))
|
||||
expect_true(nrow(unjoined) == nrow(inner))
|
||||
|
@ -22,8 +22,8 @@
|
||||
context("key_antibiotics.R")
|
||||
|
||||
test_that("keyantibiotics work", {
|
||||
expect_equal(length(key_antibiotics(septic_patients, warnings = FALSE)), nrow(septic_patients))
|
||||
expect_false(all(is.na(key_antibiotics(septic_patients))))
|
||||
expect_equal(length(key_antibiotics(example_isolates, warnings = FALSE)), nrow(example_isolates))
|
||||
expect_false(all(is.na(key_antibiotics(example_isolates))))
|
||||
expect_true(key_antibiotics_equal("SSS", "SSS"))
|
||||
expect_false(key_antibiotics_equal("SSS", "SRS"))
|
||||
expect_true(key_antibiotics_equal("SSS", "SIS", ignore_I = TRUE))
|
||||
|
@ -22,13 +22,13 @@
|
||||
context("kurtosis.R")
|
||||
|
||||
test_that("kurtosis works", {
|
||||
expect_equal(kurtosis(septic_patients$age),
|
||||
expect_equal(kurtosis(example_isolates$age),
|
||||
3.549319,
|
||||
tolerance = 0.00001)
|
||||
expect_equal(unname(kurtosis(data.frame(septic_patients$age))),
|
||||
expect_equal(unname(kurtosis(data.frame(example_isolates$age))),
|
||||
3.549319,
|
||||
tolerance = 0.00001)
|
||||
expect_equal(kurtosis(matrix(septic_patients$age)),
|
||||
expect_equal(kurtosis(matrix(example_isolates$age)),
|
||||
3.549319,
|
||||
tolerance = 0.00001)
|
||||
})
|
||||
|
@ -24,29 +24,29 @@ context("mdro.R")
|
||||
test_that("mdro works", {
|
||||
library(dplyr)
|
||||
|
||||
expect_error(suppressWarnings(mdro(septic_patients, country = "invalid", col_mo = "mo", info = TRUE)))
|
||||
expect_error(suppressWarnings(mdro(septic_patients, country = "fr", info = TRUE)))
|
||||
expect_error(mdro(septic_patients, guideline = c("BRMO", "MRGN"), info = TRUE))
|
||||
expect_error(mdro(septic_patients, col_mo = "invalid", info = TRUE))
|
||||
expect_error(suppressWarnings(mdro(example_isolates, country = "invalid", col_mo = "mo", info = TRUE)))
|
||||
expect_error(suppressWarnings(mdro(example_isolates, country = "fr", info = TRUE)))
|
||||
expect_error(mdro(example_isolates, guideline = c("BRMO", "MRGN"), info = TRUE))
|
||||
expect_error(mdro(example_isolates, col_mo = "invalid", info = TRUE))
|
||||
|
||||
outcome <- mdro(septic_patients)
|
||||
outcome <- eucast_exceptional_phenotypes(septic_patients, info = TRUE)
|
||||
outcome <- mdro(example_isolates)
|
||||
outcome <- eucast_exceptional_phenotypes(example_isolates, info = TRUE)
|
||||
# check class
|
||||
expect_equal(outcome %>% class(), c('ordered', 'factor'))
|
||||
|
||||
outcome <- mdro(septic_patients, "nl", info = TRUE)
|
||||
outcome <- mdro(example_isolates, "nl", info = TRUE)
|
||||
# check class
|
||||
expect_equal(outcome %>% class(), c('ordered', 'factor'))
|
||||
|
||||
# septic_patients should have these finding using Dutch guidelines
|
||||
# example_isolates should have these finding using Dutch guidelines
|
||||
expect_equal(outcome %>% freq() %>% pull(count),
|
||||
c(1969, 25, 6)) # 1969 neg, 25 unconfirmed, 6 pos
|
||||
|
||||
expect_equal(brmo(septic_patients, info = FALSE),
|
||||
mdro(septic_patients, guideline = "BRMO", info = FALSE))
|
||||
expect_equal(brmo(example_isolates, info = FALSE),
|
||||
mdro(example_isolates, guideline = "BRMO", info = FALSE))
|
||||
|
||||
# still working on German guidelines
|
||||
expect_error(suppressWarnings(mrgn(septic_patients, info = TRUE)))
|
||||
expect_error(suppressWarnings(mrgn(example_isolates, info = TRUE)))
|
||||
|
||||
# test Dutch P. aeruginosa MDRO
|
||||
expect_equal(
|
||||
@ -80,8 +80,8 @@ test_that("mdro works", {
|
||||
expect_equal(
|
||||
# select only rifampicine, mo will be determined automatically (as M. tuberculosis),
|
||||
# number of mono-resistant strains should be equal to number of rifampicine-resistant strains
|
||||
septic_patients %>% select(RIF) %>% mdr_tb() %>% freq() %>% pull(count) %>% .[2],
|
||||
count_R(septic_patients$RIF))
|
||||
example_isolates %>% select(RIF) %>% mdr_tb() %>% freq() %>% pull(count) %>% .[2],
|
||||
count_R(example_isolates$RIF))
|
||||
|
||||
sample_rsi <- function() {
|
||||
sample(c("S", "I", "R"),
|
||||
|
@ -42,8 +42,8 @@ test_that("functions missing in older R versions work", {
|
||||
test_that("looking up ab columns works", {
|
||||
expect_warning(generate_warning_abs_missing(c("AMP", "AMX")))
|
||||
expect_warning(generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE))
|
||||
expect_warning(get_column_abx(septic_patients, hard_dependencies = "FUS"))
|
||||
expect_message(get_column_abx(septic_patients, soft_dependencies = "FUS"))
|
||||
expect_message(get_column_abx(dplyr::rename(septic_patients, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
|
||||
expect_warning(get_column_abx(dplyr::rename(septic_patients, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
|
||||
expect_warning(get_column_abx(example_isolates, hard_dependencies = "FUS"))
|
||||
expect_message(get_column_abx(example_isolates, soft_dependencies = "FUS"))
|
||||
expect_message(get_column_abx(dplyr::rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
|
||||
expect_warning(get_column_abx(dplyr::rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
|
||||
})
|
||||
|
@ -147,7 +147,7 @@ test_that("as.mo works", {
|
||||
|
||||
# select with one column
|
||||
expect_identical(
|
||||
septic_patients[1:10,] %>%
|
||||
example_isolates[1:10,] %>%
|
||||
left_join_microorganisms() %>%
|
||||
select(genus) %>%
|
||||
as.mo() %>%
|
||||
@ -157,9 +157,9 @@ test_that("as.mo works", {
|
||||
|
||||
# select with two columns
|
||||
expect_identical(
|
||||
septic_patients[1:10,] %>%
|
||||
example_isolates[1:10,] %>%
|
||||
pull(mo),
|
||||
septic_patients[1:10,] %>%
|
||||
example_isolates[1:10,] %>%
|
||||
left_join_microorganisms() %>%
|
||||
select(genus, species) %>%
|
||||
as.mo())
|
||||
@ -168,13 +168,13 @@ test_that("as.mo works", {
|
||||
expect_warning(as.mo(c("INVALID", "Yeah, unknown")))
|
||||
|
||||
# too many columns
|
||||
expect_error(septic_patients %>% select(1:3) %>% as.mo())
|
||||
expect_error(example_isolates %>% select(1:3) %>% as.mo())
|
||||
|
||||
# print
|
||||
expect_output(print(as.mo(c("B_ESCHR_COL", NA))))
|
||||
|
||||
# test pull
|
||||
expect_equal(nrow(septic_patients %>% mutate(mo = as.mo(mo))),
|
||||
expect_equal(nrow(example_isolates %>% mutate(mo = as.mo(mo))),
|
||||
2000)
|
||||
|
||||
# test data.frame
|
||||
@ -248,7 +248,7 @@ test_that("as.mo works", {
|
||||
expect_warning(as.mo("Virus"))
|
||||
|
||||
# summary
|
||||
expect_equal(length(summary(septic_patients$mo)), 6)
|
||||
expect_equal(length(summary(example_isolates$mo)), 6)
|
||||
|
||||
# WHONET codes and NA/NaN
|
||||
expect_equal(as.character(as.mo(c("xxx", "na", "nan"), debug = TRUE)),
|
||||
@ -260,7 +260,7 @@ test_that("as.mo works", {
|
||||
rep("UNKNOWN", 3))
|
||||
|
||||
expect_null(mo_failures())
|
||||
expect_true(septic_patients %>% pull(mo) %>% is.mo())
|
||||
expect_true(example_isolates %>% pull(mo) %>% is.mo())
|
||||
|
||||
# expect_equal(get_mo_code("test", "mo"), "test")
|
||||
# expect_equal(length(get_mo_code("Escherichia", "genus")),
|
||||
@ -286,7 +286,7 @@ test_that("as.mo works", {
|
||||
expect_output(print(tibble(mo = as.mo("B_STRPT_PNE"))))
|
||||
|
||||
# assigning and subsetting
|
||||
x <- septic_patients$mo
|
||||
x <- example_isolates$mo
|
||||
expect_s3_class(x[1], "mo")
|
||||
expect_s3_class(x[[1]], "mo")
|
||||
expect_s3_class(c(x[1], x[9]), "mo")
|
||||
|
@ -22,28 +22,28 @@
|
||||
context("portion.R")
|
||||
|
||||
test_that("portions works", {
|
||||
# AMX resistance in `septic_patients`
|
||||
expect_equal(portion_R(septic_patients$AMX), 0.5557364, tolerance = 0.0001)
|
||||
expect_equal(portion_I(septic_patients$AMX), 0.002441009, tolerance = 0.0001)
|
||||
expect_equal(1 - portion_R(septic_patients$AMX) - portion_I(septic_patients$AMX),
|
||||
portion_S(septic_patients$AMX))
|
||||
expect_equal(portion_R(septic_patients$AMX) + portion_I(septic_patients$AMX),
|
||||
portion_IR(septic_patients$AMX))
|
||||
expect_equal(portion_S(septic_patients$AMX) + portion_I(septic_patients$AMX),
|
||||
portion_SI(septic_patients$AMX))
|
||||
# AMX resistance in `example_isolates`
|
||||
expect_equal(portion_R(example_isolates$AMX), 0.5557364, tolerance = 0.0001)
|
||||
expect_equal(portion_I(example_isolates$AMX), 0.002441009, tolerance = 0.0001)
|
||||
expect_equal(1 - portion_R(example_isolates$AMX) - portion_I(example_isolates$AMX),
|
||||
portion_S(example_isolates$AMX))
|
||||
expect_equal(portion_R(example_isolates$AMX) + portion_I(example_isolates$AMX),
|
||||
portion_IR(example_isolates$AMX))
|
||||
expect_equal(portion_S(example_isolates$AMX) + portion_I(example_isolates$AMX),
|
||||
portion_SI(example_isolates$AMX))
|
||||
|
||||
expect_equal(septic_patients %>% portion_SI(AMC),
|
||||
expect_equal(example_isolates %>% portion_SI(AMC),
|
||||
0.7626397,
|
||||
tolerance = 0.0001)
|
||||
expect_equal(septic_patients %>% portion_SI(AMC, GEN),
|
||||
expect_equal(example_isolates %>% portion_SI(AMC, GEN),
|
||||
0.9408,
|
||||
tolerance = 0.0001)
|
||||
expect_equal(septic_patients %>% portion_SI(AMC, GEN, only_all_tested = TRUE),
|
||||
expect_equal(example_isolates %>% portion_SI(AMC, GEN, only_all_tested = TRUE),
|
||||
0.9382647,
|
||||
tolerance = 0.0001)
|
||||
|
||||
# percentages
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
group_by(hospital_id) %>%
|
||||
summarise(R = portion_R(CIP, as_percent = TRUE),
|
||||
I = portion_I(CIP, as_percent = TRUE),
|
||||
@ -55,7 +55,7 @@ test_that("portions works", {
|
||||
1409)
|
||||
|
||||
# count of cases
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
group_by(hospital_id) %>%
|
||||
summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
|
||||
cipro_n = n_rsi(CIP),
|
||||
@ -66,14 +66,14 @@ test_that("portions works", {
|
||||
pull(combination_n),
|
||||
c(305, 617, 241, 711))
|
||||
|
||||
expect_warning(portion_R(as.character(septic_patients$AMC)))
|
||||
expect_warning(portion_S(as.character(septic_patients$AMC)))
|
||||
expect_warning(portion_S(as.character(septic_patients$AMC,
|
||||
septic_patients$GEN)))
|
||||
expect_warning(n_rsi(as.character(septic_patients$AMC,
|
||||
septic_patients$GEN)))
|
||||
expect_equal(suppressWarnings(n_rsi(as.character(septic_patients$AMC,
|
||||
septic_patients$GEN))),
|
||||
expect_warning(portion_R(as.character(example_isolates$AMC)))
|
||||
expect_warning(portion_S(as.character(example_isolates$AMC)))
|
||||
expect_warning(portion_S(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_warning(n_rsi(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_equal(suppressWarnings(n_rsi(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN))),
|
||||
1879)
|
||||
|
||||
# check for errors
|
||||
@ -86,36 +86,36 @@ test_that("portions works", {
|
||||
expect_error(portion_S("test", also_single_tested = TRUE))
|
||||
|
||||
# check too low amount of isolates
|
||||
expect_identical(suppressWarnings(portion_R(septic_patients$AMX, minimum = nrow(septic_patients) + 1)),
|
||||
expect_identical(suppressWarnings(portion_R(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
|
||||
NA)
|
||||
expect_identical(suppressWarnings(portion_I(septic_patients$AMX, minimum = nrow(septic_patients) + 1)),
|
||||
expect_identical(suppressWarnings(portion_I(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
|
||||
NA)
|
||||
expect_identical(suppressWarnings(portion_S(septic_patients$AMX, minimum = nrow(septic_patients) + 1)),
|
||||
expect_identical(suppressWarnings(portion_S(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
|
||||
NA)
|
||||
|
||||
# warning for speed loss
|
||||
expect_warning(portion_R(as.character(septic_patients$GEN)))
|
||||
expect_warning(portion_I(as.character(septic_patients$GEN)))
|
||||
expect_warning(portion_S(septic_patients$AMC, as.character(septic_patients$GEN)))
|
||||
expect_warning(portion_R(as.character(example_isolates$GEN)))
|
||||
expect_warning(portion_I(as.character(example_isolates$GEN)))
|
||||
expect_warning(portion_S(example_isolates$AMC, as.character(example_isolates$GEN)))
|
||||
|
||||
# portion_df
|
||||
expect_equal(
|
||||
septic_patients %>% select(AMX) %>% portion_df() %>% pull(value),
|
||||
c(septic_patients$AMX %>% portion_SI(),
|
||||
septic_patients$AMX %>% portion_R())
|
||||
example_isolates %>% select(AMX) %>% portion_df() %>% pull(value),
|
||||
c(example_isolates$AMX %>% portion_SI(),
|
||||
example_isolates$AMX %>% portion_R())
|
||||
)
|
||||
expect_equal(
|
||||
septic_patients %>% select(AMX) %>% portion_df(combine_IR = TRUE) %>% pull(value),
|
||||
c(septic_patients$AMX %>% portion_S(),
|
||||
septic_patients$AMX %>% portion_IR())
|
||||
example_isolates %>% select(AMX) %>% portion_df(combine_IR = TRUE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% portion_S(),
|
||||
example_isolates$AMX %>% portion_IR())
|
||||
)
|
||||
expect_equal(
|
||||
septic_patients %>% select(AMX) %>% portion_df(combine_SI = FALSE) %>% pull(value),
|
||||
c(septic_patients$AMX %>% portion_S(),
|
||||
septic_patients$AMX %>% portion_I(),
|
||||
septic_patients$AMX %>% portion_R())
|
||||
example_isolates %>% select(AMX) %>% portion_df(combine_SI = FALSE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% portion_S(),
|
||||
example_isolates$AMX %>% portion_I(),
|
||||
example_isolates$AMX %>% portion_R())
|
||||
)
|
||||
|
||||
expect_error(portion_df(c("A", "B", "C")))
|
||||
expect_error(portion_df(septic_patients[,"date"]))
|
||||
expect_error(portion_df(example_isolates[,"date"]))
|
||||
})
|
||||
|
@ -22,7 +22,7 @@
|
||||
context("resistance_predict.R")
|
||||
|
||||
test_that("prediction of rsi works", {
|
||||
AMX_R <- septic_patients %>%
|
||||
AMX_R <- example_isolates %>%
|
||||
filter(mo == "B_ESCHR_COL") %>%
|
||||
rsi_predict(col_ab = "AMX",
|
||||
col_date = "date",
|
||||
@ -30,57 +30,57 @@ test_that("prediction of rsi works", {
|
||||
minimum = 10,
|
||||
info = TRUE) %>%
|
||||
pull("value")
|
||||
# AMX resistance will increase according to data set `septic_patients`
|
||||
# AMX resistance will increase according to data set `example_isolates`
|
||||
expect_true(AMX_R[3] < AMX_R[20])
|
||||
|
||||
x <- resistance_predict(septic_patients, col_ab = "AMX", year_min = 2010, model = "binomial")
|
||||
x <- resistance_predict(example_isolates, col_ab = "AMX", year_min = 2010, model = "binomial")
|
||||
plot(x)
|
||||
ggplot_rsi_predict(x)
|
||||
expect_error(ggplot_rsi_predict(septic_patients))
|
||||
expect_error(ggplot_rsi_predict(example_isolates))
|
||||
|
||||
library(dplyr)
|
||||
|
||||
expect_output(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
model = "binomial",
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
expect_output(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
model = "loglin",
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
expect_output(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
model = "lin",
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
|
||||
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
model = "INVALID MODEL",
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
model = "binomial",
|
||||
col_ab = "NOT EXISTING COLUMN",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
model = "binomial",
|
||||
col_ab = "AMX",
|
||||
col_date = "NOT EXISTING COLUMN",
|
||||
info = TRUE))
|
||||
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
col_ab = "AMX",
|
||||
col_date = "NOT EXISTING COLUMN",
|
||||
info = TRUE))
|
||||
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
|
||||
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
col_ab = "AMX",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
# almost all E. coli are MEM S in the Netherlands :)
|
||||
expect_error(resistance_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
|
||||
expect_error(resistance_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
|
||||
model = "binomial",
|
||||
col_ab = "MEM",
|
||||
col_date = "date",
|
||||
|
@ -41,12 +41,12 @@ test_that("rsi works", {
|
||||
"-Sum R" = "1",
|
||||
"-Sum I" = "0"))
|
||||
|
||||
expect_identical(as.logical(lapply(septic_patients, is.rsi.eligible)),
|
||||
rep(FALSE, length(septic_patients)))
|
||||
expect_identical(as.logical(lapply(example_isolates, is.rsi.eligible)),
|
||||
rep(FALSE, length(example_isolates)))
|
||||
|
||||
library(dplyr)
|
||||
# 40 rsi columns
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
mutate_at(vars(PEN:RIF), as.character) %>%
|
||||
lapply(is.rsi.eligible) %>%
|
||||
as.logical() %>%
|
||||
@ -69,7 +69,7 @@ test_that("mic2rsi works", {
|
||||
guideline = "EUCAST")),
|
||||
"R")
|
||||
|
||||
expect_true(septic_patients %>%
|
||||
expect_true(example_isolates %>%
|
||||
mutate(amox_mic = as.mic(2)) %>%
|
||||
select(mo, amox_mic) %>%
|
||||
as.rsi() %>%
|
||||
@ -97,7 +97,7 @@ test_that("disk2rsi works", {
|
||||
guideline = "CLSI")),
|
||||
"R")
|
||||
|
||||
expect_true(septic_patients %>%
|
||||
expect_true(example_isolates %>%
|
||||
mutate(amox_disk = as.disk(15)) %>%
|
||||
select(mo, amox_disk) %>%
|
||||
as.rsi(guideline = "CLSI") %>%
|
||||
|
@ -22,13 +22,13 @@
|
||||
context("skewness.R")
|
||||
|
||||
test_that("skewness works", {
|
||||
expect_equal(skewness(septic_patients$age),
|
||||
expect_equal(skewness(example_isolates$age),
|
||||
-0.8958019,
|
||||
tolerance = 0.00001)
|
||||
expect_equal(unname(skewness(data.frame(septic_patients$age))),
|
||||
expect_equal(unname(skewness(data.frame(example_isolates$age))),
|
||||
-0.8958019,
|
||||
tolerance = 0.00001)
|
||||
expect_equal(skewness(matrix(septic_patients$age)),
|
||||
expect_equal(skewness(matrix(example_isolates$age)),
|
||||
-0.8958019,
|
||||
tolerance = 0.00001)
|
||||
})
|
||||
|
Reference in New Issue
Block a user