1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 11:51:59 +02:00

(v0.7.1.9005) new rsi calculations, atc class removal

This commit is contained in:
2019-07-01 14:03:15 +02:00
parent 65c6702b21
commit 156d550895
78 changed files with 1169 additions and 911 deletions

View File

@ -33,20 +33,22 @@ test_that("counts work", {
library(dplyr)
expect_equal(septic_patients %>% count_S(AMC), 1342)
expect_equal(septic_patients %>% count_S(AMC, GEN), 1660)
expect_equal(septic_patients %>% count_all(AMC, GEN), 1798)
expect_identical(septic_patients %>% count_all(AMC, GEN),
septic_patients %>% count_S(AMC, GEN) +
septic_patients %>% count_IR(AMC, GEN))
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))
# count of cases
expect_equal(septic_patients %>%
group_by(hospital_id) %>%
summarise(cipro = count_S(CIP),
genta = count_S(GEN),
combination = count_S(CIP, GEN)) %>%
summarise(cipro = count_SI(CIP),
genta = count_SI(GEN),
combination = count_SI(CIP, GEN)) %>%
pull(combination),
c(192, 446, 184, 474))
c(253, 465, 192, 558))
# count_df
expect_equal(

View File

@ -32,14 +32,14 @@ test_that("portions works", {
expect_equal(portion_S(septic_patients$AMX) + portion_I(septic_patients$AMX),
portion_SI(septic_patients$AMX))
expect_equal(septic_patients %>% portion_S(AMC),
0.7142097,
expect_equal(septic_patients %>% portion_SI(AMC),
0.7626397,
tolerance = 0.0001)
expect_equal(septic_patients %>% portion_S(AMC, GEN),
0.9232481,
expect_equal(septic_patients %>% portion_SI(AMC, GEN),
0.9408,
tolerance = 0.0001)
expect_equal(septic_patients %>% portion_S(AMC, GEN, also_single_tested = TRUE),
0.926045,
expect_equal(septic_patients %>% portion_SI(AMC, GEN, only_all_tested = TRUE),
0.9382647,
tolerance = 0.0001)
# percentages
@ -57,14 +57,14 @@ test_that("portions works", {
# count of cases
expect_equal(septic_patients %>%
group_by(hospital_id) %>%
summarise(CIPo_p = portion_S(CIP, as_percent = TRUE),
CIPo_n = n_rsi(CIP),
GENa_p = portion_S(GEN, as_percent = TRUE),
GENa_n = n_rsi(GEN),
combination_p = portion_S(CIP, GEN, as_percent = TRUE),
summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
cipro_n = n_rsi(CIP),
genta_p = portion_SI(GEN, as_percent = TRUE),
genta_n = n_rsi(GEN),
combination_p = portion_SI(CIP, GEN, as_percent = TRUE),
combination_n = n_rsi(CIP, GEN)) %>%
pull(combination_n),
c(202, 488, 201, 499))
c(305, 617, 241, 711))
expect_warning(portion_R(as.character(septic_patients$AMC)))
expect_warning(portion_S(as.character(septic_patients$AMC)))
@ -83,7 +83,7 @@ test_that("portions works", {
expect_error(portion_I("test", as_percent = "test"))
expect_error(portion_S("test", minimum = "test"))
expect_error(portion_S("test", as_percent = "test"))
expect_error(portion_S("test", also_single_tested = "test"))
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)),