mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 15:21:58 +02:00
first isolate missing dates fix
This commit is contained in:
@ -25,7 +25,7 @@ test_that("first isolates work", {
|
||||
# first isolates
|
||||
expect_equal(
|
||||
sum(
|
||||
first_isolate(tbl = septic_patients,
|
||||
first_isolate(x = septic_patients,
|
||||
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(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = septic_patients %>% 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(tbl = septic_patients %>% dplyr::as_tibble() %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = septic_patients %>% 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(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = septic_patients %>% 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(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_mo = "mo",
|
||||
@ -106,7 +106,7 @@ test_that("first isolates work", {
|
||||
random_rows <- sample(x = 1:2000, size = 1500, replace = FALSE)
|
||||
expect_lt(
|
||||
sum(
|
||||
first_isolate(tbl = mutate(septic_patients,
|
||||
first_isolate(x = mutate(septic_patients,
|
||||
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(tbl = mutate(septic_patients,
|
||||
first_isolate(x = mutate(septic_patients,
|
||||
specimen = if_else(row_number() %in% random_rows,
|
||||
"Urine",
|
||||
"Other")),
|
||||
@ -175,4 +175,16 @@ test_that("first isolates work", {
|
||||
col_mo = "mo",
|
||||
col_patient_id = "patient_id"))
|
||||
|
||||
df <- septic_patients
|
||||
df[1:100, "date"] <- NA
|
||||
expect_equal(
|
||||
sum(
|
||||
first_isolate(x = df,
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_mo = "mo",
|
||||
info = TRUE),
|
||||
na.rm = TRUE),
|
||||
1279)
|
||||
|
||||
})
|
||||
|
Reference in New Issue
Block a user