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

MDRO, freq tables, new print format for tibbles

This commit is contained in:
2018-04-18 12:24:54 +02:00
parent 3165c50d06
commit 2509e2413d
23 changed files with 1453 additions and 85 deletions

View File

@ -1,4 +1,4 @@
context("EUCAST.R")
context("eucast.R")
test_that("EUCAST rules work", {
a <- data.frame(bactid = c("KLEPNE", # Klebsiella pneumoniae

View File

@ -0,0 +1,26 @@
context("freq.R")
test_that("frequency table works", {
expect_equal(nrow(freq(c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5), toConsole = FALSE)), 5)
expect_equal(nrow(frequency_tbl(c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5), toConsole = FALSE)), 5)
# date column of septic_patients should contain 1662 unique dates
expect_equal(nrow(freq(septic_patients$date, toConsole = FALSE)), 1662)
expect_equal(nrow(freq(septic_patients$date, toConsole = FALSE)),
length(unique(septic_patients$date)))
expect_output(freq(septic_patients$age))
expect_output(freq(septic_patients$date))
expect_output(freq(septic_patients$hospital_id))
library(dplyr)
expect_output(septic_patients %>% select(1:2) %>% freq())
expect_output(septic_patients %>% select(1:3) %>% freq())
expect_output(septic_patients %>% select(1:4) %>% freq())
expect_output(septic_patients %>% select(1:5) %>% freq())
expect_output(septic_patients %>% select(1:6) %>% freq())
expect_output(septic_patients %>% select(1:7) %>% freq())
expect_output(septic_patients %>% select(1:8) %>% freq())
expect_output(septic_patients %>% select(1:9) %>% freq())
})

View File

@ -0,0 +1,16 @@
context("mdro.R")
test_that("MDRO works", {
library(dplyr)
outcome <- MDRO(septic_patients, "nl", info = FALSE)
# check class
expect_equal(outcome %>% class(), c('ordered', 'factor'))
# septic_patients should have these finding using Dutch guidelines
expect_equal(outcome %>% freq(toConsole = FALSE) %>% pull(Count), c(1152, 824, 3, 21))
expect_equal(BRMO(septic_patients, info = FALSE), MDRO(septic_patients, "nl", info = FALSE))
})

View File

@ -10,5 +10,7 @@ test_that("`like` works", {
test_that("percentages works", {
expect_equal(percent(0.25), "25%")
expect_equal(percent(0.5), "50%")
expect_equal(percent(0.500, force_zero = TRUE), "50.0%")
expect_equal(percent(0.1234), "12.3%")
})

View File

@ -0,0 +1,8 @@
context("print.R")
test_that("tibble printing works", {
library(dplyr)
expect_output(print(starwars))
expect_output(print(septic_patients))
})