First isolate: ICU filtering based on wrong ordering
msberends opened this issue · comments
Matthijs Berends commented
See:
Line 594 in 5f9769a
This is not the case for col_icu
:
library(AMR)
library(dplyr)
example_isolates %>%
mutate(first = first_isolate(col_icu = ward == "ICU",
icu_exclude = TRUE)) %>%
count(ward, first)
#> Determining first isolates using an episode length of 365 days
#> ℹ Using column 'mo' as input for col_mo.
#> ℹ Using column 'date' as input for col_date.
#> ℹ Using column 'patient' as input for col_patient_id.
#> Basing inclusion on all antimicrobial results, using a points threshold of 2
#> Excluding 646 isolates from ICU.
#> ℹ Excluded 16 isolates with a microbial ID 'UNKNOWN' (in column 'mo')
#> => Found 942 'phenotype-based' first isolates (47.1% of total where a microbial ID was available)
#> # A tibble: 6 × 3
#> ward first n
#> <chr> <lgl> <int>
#> 1 Clinical FALSE 659
#> 2 Clinical TRUE 575
#> 3 ICU FALSE 346
#> 4 ICU TRUE 300
#> 5 Outpatient FALSE 53
#> 6 Outpatient TRUE 67
Should not contain TRUE in ICU group.