mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 16:02:02 +02:00
count_all and some fixes
This commit is contained in:
@ -10,8 +10,8 @@ test_that("atc_property works", {
|
||||
expect_equal(atc_property("J01CA04", property = "DDD"),
|
||||
atc_ddd("J01CA04"))
|
||||
|
||||
expect_identical(atc_property("J01CA04", property = "Groups"),
|
||||
atc_groups("J01CA04"))
|
||||
# expect_identical(atc_property("J01CA04", property = "Groups"),
|
||||
# atc_groups("J01CA04"))
|
||||
|
||||
expect_warning(atc_property("ABCDEFG", property = "DDD"))
|
||||
|
||||
|
@ -10,8 +10,13 @@ test_that("counts work", {
|
||||
expect_equal(count_S(septic_patients$amox) + count_I(septic_patients$amox),
|
||||
count_SI(septic_patients$amox))
|
||||
|
||||
library(dplyr)
|
||||
expect_equal(septic_patients %>% count_S(amcl), 1057)
|
||||
expect_equal(septic_patients %>% count_S(amcl, gent), 1396)
|
||||
expect_equal(septic_patients %>% count_all(amcl, gent), 1517)
|
||||
expect_identical(septic_patients %>% count_all(amcl, gent),
|
||||
septic_patients %>% count_S(amcl, gent) +
|
||||
septic_patients %>% count_IR(amcl, gent))
|
||||
|
||||
# count of cases
|
||||
expect_equal(septic_patients %>%
|
||||
|
@ -43,6 +43,11 @@ test_that("frequency table works", {
|
||||
# list
|
||||
expect_output(print(freq(list(age = septic_patients$age))))
|
||||
expect_output(print(freq(list(age = septic_patients$age, gender = septic_patients$gender))))
|
||||
# difftime
|
||||
expect_output(suppressWarnings(print(
|
||||
freq(difftime(Sys.time(),
|
||||
Sys.time() - runif(5, min = 0, max = 60 * 60 * 24),
|
||||
units = "hours")))))
|
||||
|
||||
library(dplyr)
|
||||
expect_output(septic_patients %>% select(1:2) %>% freq() %>% print())
|
||||
@ -119,7 +124,7 @@ test_that("frequency table works", {
|
||||
))
|
||||
expect_output(print(
|
||||
diff(freq(septic_patients$age),
|
||||
freq(septic_patients$age)) # same
|
||||
freq(septic_patients$age)) # "No differences found."
|
||||
))
|
||||
expect_error(print(
|
||||
diff(freq(septic_patients$amcl),
|
||||
|
@ -68,11 +68,11 @@ test_that("portions works", {
|
||||
expect_error(portion_S("test", as_percent = "test"))
|
||||
|
||||
# check too low amount of isolates
|
||||
expect_identical(portion_R(septic_patients$amox, minimum = nrow(septic_patients) + 1),
|
||||
expect_identical(suppressWarnings(portion_R(septic_patients$amox, minimum = nrow(septic_patients) + 1)),
|
||||
NA)
|
||||
expect_identical(portion_I(septic_patients$amox, minimum = nrow(septic_patients) + 1),
|
||||
expect_identical(suppressWarnings(portion_I(septic_patients$amox, minimum = nrow(septic_patients) + 1)),
|
||||
NA)
|
||||
expect_identical(portion_S(septic_patients$amox, minimum = nrow(septic_patients) + 1),
|
||||
expect_identical(suppressWarnings(portion_S(septic_patients$amox, minimum = nrow(septic_patients) + 1)),
|
||||
NA)
|
||||
|
||||
# warning for speed loss
|
||||
|
Reference in New Issue
Block a user