1
0
mirror of https://github.com/msberends/AMR.git synced 2025-09-06 06:49:41 +02:00

new portion functions

This commit is contained in:
2018-08-10 15:01:05 +02:00
parent ae2433a020
commit 53fa198e35
19 changed files with 892 additions and 1140 deletions

View File

@@ -75,31 +75,32 @@ Determine first (weighted) isolates of all microorganisms of every patient per e
}
\examples{
# septic_patients is a dataset available in the AMR package
# septic_patients is a dataset available in the AMR package. It is true data.
?septic_patients
my_patients <- septic_patients
library(dplyr)
my_patients$first_isolate <- my_patients \%>\%
first_isolate(col_date = "date",
col_patient_id = "patient_id",
col_bactid = "bactid")
my_patients <- septic_patients \%>\%
mutate(first_isolate = first_isolate(.,
col_date = "date",
col_patient_id = "patient_id",
col_bactid = "bactid"))
# Now let's see if first isolates matter:
A <- my_patients \%>\%
group_by(hospital_id) \%>\%
summarise(count = n_rsi(gent), # gentamicin
resistance = resistance(gent))
summarise(count = n_rsi(gent), # gentamicin availability
resistance = portion_IR(gent)) # gentamicin resistance
B <- my_patients \%>\%
filter(first_isolate == TRUE) \%>\% # the 1st isolate filter
filter(first_isolate == TRUE) \%>\% # the 1st isolate filter
group_by(hospital_id) \%>\%
summarise(count = n_rsi(gent),
resistance = resistance(gent))
summarise(count = n_rsi(gent), # gentamicin availability
resistance = portion_IR(gent)) # gentamicin resistance
# Have a look at A and B. B is more reliable because every isolate is
# counted once. Gentamicin resitance in hospital D appears to be 5\%
# higher than originally thought.
# Have a look at A and B.
# B is more reliable because every isolate is only counted once.
# Gentamicin resitance in hospital D appears to be 5.4\% higher than
# when you (erroneously) would have used all isolates!
## OTHER EXAMPLES: