vignettes/AMR.Rmd
AMR.Rmd
Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 28 May 2020.
+Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 17 June 2020.
Using the sample()
function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the prob
parameter.
Using the sample()
function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the prob
parameter.
sample_size <- 20000 -data <- data.frame(date = sample(dates, size = sample_size, replace = TRUE), - patient_id = sample(patients, size = sample_size, replace = TRUE), - hospital = sample(hospitals, size = sample_size, replace = TRUE, +data <- data.frame(date = sample(dates, size = sample_size, replace = TRUE), + patient_id = sample(patients, size = sample_size, replace = TRUE), + hospital = sample(hospitals, size = sample_size, replace = TRUE, prob = c(0.30, 0.35, 0.15, 0.20)), - bacteria = sample(bacteria, size = sample_size, replace = TRUE, + bacteria = sample(bacteria, size = sample_size, replace = TRUE, prob = c(0.50, 0.25, 0.15, 0.10)), - AMX = sample(ab_interpretations, size = sample_size, replace = TRUE, + AMX = sample(ab_interpretations, size = sample_size, replace = TRUE, prob = c(0.60, 0.05, 0.35)), - AMC = sample(ab_interpretations, size = sample_size, replace = TRUE, + AMC = sample(ab_interpretations, size = sample_size, replace = TRUE, prob = c(0.75, 0.10, 0.15)), - CIP = sample(ab_interpretations, size = sample_size, replace = TRUE, + CIP = sample(ab_interpretations, size = sample_size, replace = TRUE, prob = c(0.80, 0.00, 0.20)), - GEN = sample(ab_interpretations, size = sample_size, replace = TRUE, + GEN = sample(ab_interpretations, size = sample_size, replace = TRUE, prob = c(0.92, 0.00, 0.08)))
Using the left_join()
function from the dplyr
package, we can ‘map’ the gender to the patient ID using the patients_table
object we created earlier:
data <- data %>% left_join(patients_table)
Using the left_join()
function from the dplyr
package, we can ‘map’ the gender to the patient ID using the patients_table
object we created earlier:
data <- data %>% left_join(patients_table)
The resulting data set contains 20,000 blood culture isolates. With the head()
function we can preview the first 6 rows of this data set:
head(data)
2013-12-18 | -P10 | +2014-09-10 | +V9 | Hospital A | -Escherichia coli | +Streptococcus pneumoniae | R | S | S | @@ -347,32 +347,10 @@F | ||||
2010-07-10 | -K6 | -Hospital C | -Escherichia coli | -S | -S | -S | -S | -M | -||||||
2014-12-14 | -F6 | -Hospital C | -Escherichia coli | -S | -S | -S | -S | -M | -||||||
2010-12-31 | -N8 | -Hospital D | -Escherichia coli | +2011-09-21 | +Y7 | +Hospital B | +Streptococcus pneumoniae | S | S | S | @@ -380,23 +358,45 @@F | |||
2010-11-24 | -M5 | +2014-05-27 | +U4 | +Hospital B | +Klebsiella pneumoniae | +S | +S | +S | +S | +F | +||||
2013-01-03 | +I8 | Hospital B | Escherichia coli | -S | -S | -S | +R | +R | +R | S | M | |||
2011-06-08 | +K4 | +Hospital B | +Streptococcus pneumoniae | +S | +S | +S | +R | +M | +||||||
2010-10-07 | -Z8 | -Hospital C | -Escherichia coli | -R | -R | +2017-09-29 | +T5 | +Hospital A | +Staphylococcus aureus | +S | +I | S | S | F | @@ -432,16 +432,16 @@ Longest: 1
1 | M | -10,397 | -51.99% | -10,397 | -51.99% | +10,319 | +51.60% | +10,319 | +51.60% | |||||
2 | F | -9,603 | -48.02% | +9,681 | +48.41% | 20,000 | 100.00% |