1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 00:02:38 +02:00

quasiquotation, alpha for geom_rsi

This commit is contained in:
2018-08-23 00:40:36 +02:00
parent 43ba16f8ed
commit da5379c881
18 changed files with 304 additions and 235 deletions

View File

@ -1,8 +1,7 @@
context("atc.R")
test_that("atc_property works", {
skip_on_travis() # relies on internet connection of server, don't test
skip_on_cran() # relies on internet connection of server, don't test
skip_on_appveyor() # security error on AppVeyor
if (!is.null(curl::nslookup("www.whocc.no", error = FALSE))) {

View File

@ -0,0 +1,41 @@
context("count.R")
test_that("counts work", {
# amox resistance in `septic_patients`
expect_equal(count_R(septic_patients$amox), 659)
expect_equal(count_I(septic_patients$amox), 3)
expect_equal(count_S(septic_patients$amox), 336)
expect_equal(count_R(septic_patients$amox) + count_I(septic_patients$amox),
count_IR(septic_patients$amox))
expect_equal(count_S(septic_patients$amox) + count_I(septic_patients$amox),
count_SI(septic_patients$amox))
expect_equal(septic_patients %>% count_S(amcl), 1056)
expect_equal(septic_patients %>% count_S(amcl, gent), 1385)
# count of cases
expect_equal(septic_patients %>%
group_by(hospital_id) %>%
summarise(cipro = count_S(cipr),
genta = count_S(gent),
combination = count_S(cipr, gent)) %>%
pull(combination),
c(192, 440, 184, 474))
# warning for speed loss
expect_warning(count_R(as.character(septic_patients$amcl)))
expect_warning(count_I(as.character(septic_patients$amcl)))
expect_warning(count_S(as.character(septic_patients$amcl,
septic_patients$gent)))
expect_warning(count_S(septic_patients$amcl,
as.character(septic_patients$gent)))
# check for errors
expect_error(count_IR("test", minimum = "test"))
expect_error(count_IR("test", as_percent = "test"))
expect_error(count_I("test", minimum = "test"))
expect_error(count_I("test", as_percent = "test"))
expect_error(count_S("test", minimum = "test"))
expect_error(count_S("test", as_percent = "test"))
})

View File

@ -11,12 +11,19 @@ test_that("portions works", {
expect_equal(portion_S(septic_patients$amox) + portion_I(septic_patients$amox),
portion_SI(septic_patients$amox))
# pita+genta susceptibility around 98.09%
expect_equal(suppressWarnings(rsi(septic_patients$pita,
expect_equal(septic_patients %>% portion_S(amcl),
0.673,
tolerance = 0.001)
expect_equal(septic_patients %>% portion_S(amcl, gent),
0.921,
tolerance = 0.001)
# amcl+genta susceptibility around 92.1%
expect_equal(suppressWarnings(rsi(septic_patients$amcl,
septic_patients$gent,
interpretation = "S")),
0.9535,
tolerance = 0.0001)
0.9208777,
tolerance = 0.000001)
# percentages
expect_equal(septic_patients %>%
@ -46,25 +53,19 @@ test_that("portions works", {
expect_warning(portion_S(as.character(septic_patients$amcl)))
expect_warning(portion_S(as.character(septic_patients$amcl,
septic_patients$gent)))
expect_equal(n_rsi(as.character(septic_patients$amcl,
septic_patients$gent)),
expect_warning(n_rsi(as.character(septic_patients$amcl,
septic_patients$gent)))
expect_equal(suppressWarnings(n_rsi(as.character(septic_patients$amcl,
septic_patients$gent))),
1570)
# check for errors
expect_error(portion_IR(septic_patients %>% select(amox, amcl)))
expect_error(portion_IR("test", minimum = "test"))
expect_error(portion_IR("test", as_percent = "test"))
expect_error(portion_I(septic_patients %>% select(amox, amcl)))
expect_error(portion_I("test", minimum = "test"))
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(septic_patients %>% select(amox, amcl)))
expect_error(portion_S("R", septic_patients %>% select(amox, amcl)))
expect_error(n_rsi(septic_patients %>% select(amox, amcl)))
expect_error(n_rsi(septic_patients$amox, septic_patients %>% select(amox, amcl)))
# check too low amount of isolates
expect_identical(portion_R(septic_patients$amox, minimum = nrow(septic_patients) + 1),