1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-12 20:21:58 +02:00

bring back antibiogram(), without deps

This commit is contained in:
2023-02-10 16:18:00 +01:00
parent 70a7ba0206
commit bc434db835
42 changed files with 11307 additions and 4734 deletions

View File

@ -85,9 +85,27 @@ if (require("dplyr")) {
)
}
# grouping on patients and microorganisms leads to the same
# results as first_isolate() when using 'episode-based':
if (require("dplyr")) {
# is_new_episode() has a lot more flexibility than first_isolate(),
# since you can group on anything that seems relevant:
x <- df \%>\%
filter_first_isolate(
include_unknown = TRUE,
method = "episode-based"
)
y <- df \%>\%
group_by(patient, mo) \%>\%
filter(is_new_episode(date, 365)) \%>\%
ungroup()
identical(x, y)
}
# but is_new_episode() has a lot more flexibility than first_isolate(),
# since you can now group on anything that seems relevant:
if (require("dplyr")) {
df \%>\%
group_by(patient, mo, ward) \%>\%
mutate(flag_episode = is_new_episode(date, 365)) \%>\%