Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by using evidence-based methods, as described in https://doi.org/10.18637/jss.v104.i03.
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
See:
https://github.com/msberends/AMR/blob/5f9769a4f7a28b6dc0d29a5d0bda6cf439a83fd5/R/first_isolate.R#L594
This is not the case for
col_icu
:Should not contain TRUE in ICU group.