mirror of
https://github.com/msberends/AMR.git
synced 2025-07-13 00:32:34 +02:00
(v1.3.0.9035) mdro() for EUCAST 3.2, examples cleanup
This commit is contained in:
@ -98,15 +98,16 @@ To conduct an analysis of antimicrobial resistance, you should only include the
|
||||
|
||||
All isolates with a microbial ID of \code{NA} will be excluded as first isolate.
|
||||
|
||||
The functions \code{\link[=filter_first_isolate]{filter_first_isolate()}} and \code{\link[=filter_first_weighted_isolate]{filter_first_weighted_isolate()}} are helper functions to quickly filter on first isolates. The function \code{\link[=filter_first_isolate]{filter_first_isolate()}} is essentially equal to one of:\preformatted{ x \%>\% filter(first_isolate(., ...))
|
||||
The functions \code{\link[=filter_first_isolate]{filter_first_isolate()}} and \code{\link[=filter_first_weighted_isolate]{filter_first_weighted_isolate()}} are helper functions to quickly filter on first isolates. The function \code{\link[=filter_first_isolate]{filter_first_isolate()}} is essentially equal to either:\preformatted{ x[first_isolate(x, ...), ]
|
||||
x \%>\% filter(first_isolate(x, ...))
|
||||
}
|
||||
|
||||
The function \code{\link[=filter_first_weighted_isolate]{filter_first_weighted_isolate()}} is essentially equal to:\preformatted{ x \%>\%
|
||||
mutate(keyab = key_antibiotics(.)) \%>\%
|
||||
mutate(only_weighted_firsts = first_isolate(x,
|
||||
col_keyantibiotics = "keyab", ...)) \%>\%
|
||||
filter(only_weighted_firsts == TRUE) \%>\%
|
||||
select(-only_weighted_firsts, -keyab)
|
||||
The function \code{\link[=filter_first_weighted_isolate]{filter_first_weighted_isolate()}} is essentially equal to:\preformatted{ x \%>\%
|
||||
mutate(keyab = key_antibiotics(.)) \%>\%
|
||||
mutate(only_weighted_firsts = first_isolate(x,
|
||||
col_keyantibiotics = "keyab", ...)) \%>\%
|
||||
filter(only_weighted_firsts == TRUE) \%>\%
|
||||
select(-only_weighted_firsts, -keyab)
|
||||
}
|
||||
}
|
||||
\section{Key antibiotics}{
|
||||
@ -139,49 +140,40 @@ On our website \url{https://msberends.github.io/AMR} you can find \href{https://
|
||||
# `example_isolates` is a dataset available in the AMR package.
|
||||
# See ?example_isolates.
|
||||
|
||||
\dontrun{
|
||||
library(dplyr)
|
||||
# Filter on first isolates:
|
||||
example_isolates \%>\%
|
||||
mutate(first_isolate = first_isolate(.)) \%>\%
|
||||
filter(first_isolate == TRUE)
|
||||
# basic filtering on first isolates
|
||||
example_isolates[first_isolate(example_isolates), ]
|
||||
|
||||
# Now let's see if first isolates matter:
|
||||
A <- example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(count = n_rsi(GEN), # gentamicin availability
|
||||
resistance = resistance(GEN)) # gentamicin resistance
|
||||
|
||||
B <- example_isolates \%>\%
|
||||
filter_first_weighted_isolate() \%>\% # the 1st isolate filter
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(count = n_rsi(GEN), # gentamicin availability
|
||||
resistance = resistance(GEN)) # gentamicin resistance
|
||||
|
||||
# Have a look at A and B.
|
||||
# B is more reliable because every isolate is counted only once.
|
||||
# Gentamicin resistance in hospital D appears to be 3.7\% higher than
|
||||
# when you (erroneously) would have used all isolates for analysis.
|
||||
|
||||
|
||||
## OTHER EXAMPLES:
|
||||
|
||||
# Short-hand versions:
|
||||
example_isolates \%>\%
|
||||
filter_first_isolate()
|
||||
\donttest{
|
||||
if (require("dplyr")) {
|
||||
# Filter on first isolates:
|
||||
example_isolates \%>\%
|
||||
mutate(first_isolate = first_isolate(.)) \%>\%
|
||||
filter(first_isolate == TRUE)
|
||||
|
||||
# Short-hand versions:
|
||||
example_isolates \%>\%
|
||||
filter_first_isolate()
|
||||
|
||||
example_isolates \%>\%
|
||||
filter_first_weighted_isolate()
|
||||
|
||||
example_isolates \%>\%
|
||||
filter_first_weighted_isolate()
|
||||
|
||||
|
||||
# set key antibiotics to a new variable
|
||||
x$keyab <- key_antibiotics(x)
|
||||
|
||||
x$first_isolate <- first_isolate(x)
|
||||
|
||||
x$first_isolate_weighed <- first_isolate(x, col_keyantibiotics = 'keyab')
|
||||
|
||||
x$first_blood_isolate <- first_isolate(x, specimen_group = "Blood")
|
||||
# Now let's see if first isolates matter:
|
||||
A <- example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(count = n_rsi(GEN), # gentamicin availability
|
||||
resistance = resistance(GEN)) # gentamicin resistance
|
||||
|
||||
B <- example_isolates \%>\%
|
||||
filter_first_weighted_isolate() \%>\% # the 1st isolate filter
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(count = n_rsi(GEN), # gentamicin availability
|
||||
resistance = resistance(GEN)) # gentamicin resistance
|
||||
|
||||
# Have a look at A and B.
|
||||
# B is more reliable because every isolate is counted only once.
|
||||
# Gentamicin resistance in hospital D appears to be 3.7\% higher than
|
||||
# when you (erroneously) would have used all isolates for analysis.
|
||||
}
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
|
Reference in New Issue
Block a user