diff --git a/DESCRIPTION b/DESCRIPTION index fecbee04..bf339b15 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.7.1.9029 -Date: 2019-08-07 +Version: 0.7.1.9030 +Date: 2019-08-08 Title: Antimicrobial Resistance Analysis Authors@R: c( person( @@ -15,11 +15,6 @@ Authors@R: c( email = "c.f.luz@umcg.nl", role = "aut", comment = c(ORCID = "0000-0001-5809-5995")), - person( - given = c("Erwin", "E.", "A."), - family = "Hassing", - email = "e.hassing@certe.nl", - role = "ctb"), person( given = "Corinna", family = "Glasner", @@ -37,7 +32,22 @@ Authors@R: c( family = "Sinha", email = "b.sinha@umcg.nl", role = c("aut", "ths"), - comment = c(ORCID = "0000-0003-1634-0010"))) + comment = c(ORCID = "0000-0003-1634-0010")), + person( + given = c("Erwin", "E.", "A."), + family = "Hassing", + email = "e.hassing@certe.nl", + role = "ctb"), + person( + given = c("Bart", "C."), + family = "Meijer", + email = "b.meijerg@certe.nl", + role = "ctb"), + person( + given = "Dennis", + family = "Souverein", + email = "d.souvereing@streeklabhaarlem.nl", + role = "ctb")) Description: Functions to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods. diff --git a/NEWS.md b/NEWS.md index 8e79b00e..8d177188 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 0.7.1.9029 +# AMR 0.7.1.9030 ### Breaking * Function `freq()` has moved to a new package, [`clean`](https://github.com/msberends/clean) ([CRAN link](https://cran.r-project.org/package=clean)). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. Therefore, a new package was created for data cleaning and checking and it perfectly fits the `freq()` function. The [`clean`](https://github.com/msberends/clean) package is available on CRAN and will be installed automatically when updating the `AMR` package, that now imports it. In a later stage, the `skewness()` and `kurtosis()` functions will be moved to the `clean` package too. @@ -36,6 +36,7 @@ ### Changed * Added more informative errors and warnings to `eucast_rules()` +* Fixed a bug in `eucast_rules()` where antibiotic columns would be read as lists instead of characters * Added tibble printing support for classes `rsi`, `mic`, `ab` and `mo`. When using tibbles containing antibiotic columns, values `S` will print in green, values `I` will print in yellow and values `R` will print in red: ```r (run this on your own console, as this page does not support colour printing) @@ -63,6 +64,9 @@ * Speed improvement for `guess_ab_col()` which is now 30 times faster for antibiotic abbreviations * Using factors as input for `eucast_rules()` now adds missing factors levels when the function changes antibiotic results +#### Other +* Added Dr Bart Meijer and Dr Dennis Souverein as contributors + # AMR 0.7.1 #### New diff --git a/R/eucast_rules.R b/R/eucast_rules.R index ae683861..af1e5e80 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -416,10 +416,12 @@ eucast_rules <- function(x, }, error = function(e) { txt_error() - stop(paste0("Error in row(s) ", paste(rows[1:min(length(rows), 10)], collapse = ","), - '... while writing value "', to, + stop(paste0("In row(s) ", paste(rows[1:min(length(rows), 10)], collapse = ","), + ifelse(length(rows) > 10, "...", ""), + ' while writing value "', to, '" to column(s) `', paste(cols, collapse = "`, `"), - "` (data class:", paste(class(x_original), collapse = "/"), "):\n", e$message), call. = FALSE) + "` (data class: ", paste(class(x_original), collapse = "/"), "):\n", e$message), + call. = FALSE) } ) @@ -520,6 +522,9 @@ eucast_rules <- function(x, x <- trimws(unlist(strsplit(x, ",", fixed = TRUE))) y <- character(0) for (i in 1:length(x)) { + if (is.function(get(x[i]))) { + stop("Column ", x[i], " is also a function. Please create an issue on github.com/msberends/AMR/issues.") + } y <- c(y, tryCatch(get(x[i]), error = function(e) "")) } y[y != "" & y %in% colnames(df)] @@ -736,7 +741,7 @@ eucast_rules <- function(x, mutate(plural = ifelse(n > 1, "s", ""), txt = paste0(formatnr(n), " test result", plural, " added as ", new)) %>% pull(txt) %>% - paste(" *", ., collapse = "\n") %>% + paste(" -", ., collapse = "\n") %>% cat() } @@ -765,7 +770,7 @@ eucast_rules <- function(x, mutate(plural = ifelse(n > 1, "s", ""), txt = paste0(formatnr(n), " test result", plural, " changed from ", old, " to ", new)) %>% pull(txt) %>% - paste(" *", ., collapse = "\n") %>% + paste(" -", ., collapse = "\n") %>% cat() cat("\n") } @@ -774,7 +779,7 @@ eucast_rules <- function(x, if (verbose == FALSE & nrow(verbose_info) > 0) { cat(paste("\nUse", bold("eucast_rules(..., verbose = TRUE)"), "(on your original data) to get a data.frame with all specified edits instead.\n\n")) } else if (verbose == TRUE) { - cat(paste(red("\nUsed 'Verbose mode' (verbose = TRUE)"), ", which returns a data.frame with all specified edits.\nUse", bold("verbose = FALSE"), "to apply the rules on your data.\n\n")) + cat(paste0("\nUsed 'Verbose mode' (", bold("verbose = TRUE"), "), which returns a data.frame with all specified edits.\nUse ", bold("verbose = FALSE"), " to apply the rules on your data.\n\n")) } } diff --git a/R/sysdata.rda b/R/sysdata.rda index c24a8039..5c44c6ce 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/eucast_rules.tsv b/data-raw/eucast_rules.tsv index 4b822a63..664994a0 100644 --- a/data-raw/eucast_rules.tsv +++ b/data-raw/eucast_rules.tsv @@ -126,7 +126,7 @@ genus_species is Providencia stuartii aminopenicillins, AMC, CZO, CXM, tetracy genus is Raoultella aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules genus_species is Serratia marcescens aminopenicillins, AMC, CZO, FOX, CXM, DOX, TCY, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules genus_species is Yersinia enterocolitica aminopenicillins, AMC, TIC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Yersinia pseudotuberculosis poly, COL R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Yersinia pseudotuberculosis PLB, COL R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordatella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, FOX, CXM, glycopeptides, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules genus_species is Acinetobacter baumannii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules genus_species is Acinetobacter pittii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 0ae1a683..41b7e4cd 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.1.9029 + 0.7.1.9030 diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 6e853524..6f8c16c6 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -40,7 +40,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 @@ -185,7 +185,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

07 August 2019

+

08 August 2019

@@ -194,7 +194,7 @@ -

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 07 August 2019.

+

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 08 August 2019.

Introduction

@@ -210,21 +210,21 @@ -2019-08-07 +2019-08-08 abcd Escherichia coli S S -2019-08-07 +2019-08-08 abcd Escherichia coli S R -2019-08-07 +2019-08-08 efgh Escherichia coli R @@ -320,69 +320,69 @@ -2017-01-02 -V8 -Hospital A +2017-01-03 +T3 +Hospital D +Staphylococcus aureus +S +I +S +S +F + + +2012-11-05 +F9 +Hospital D +Streptococcus pneumoniae +S +S +S +S +M + + +2011-12-06 +I5 +Hospital C Klebsiella pneumoniae -S -I +R S S -F +S +M -2013-05-08 -W2 -Hospital B -Staphylococcus aureus -R -S -S -S -F - - -2015-08-15 -R1 -Hospital B -Streptococcus pneumoniae -S -S -S -R -F - - -2012-01-09 -X9 -Hospital D -Staphylococcus aureus -S -I -R -S -F - - -2014-06-18 -Z7 +2011-03-10 +B9 Hospital D Streptococcus pneumoniae +R +R +R S -S -S -S -F +M - -2015-02-18 -F4 -Hospital A + +2010-06-27 +A2 +Hospital D Escherichia coli +S +S +S +S +M + + +2017-12-11 +F8 +Hospital A +Streptococcus pneumoniae R S -S -S +R +R M @@ -406,8 +406,8 @@ # # Item Count Percent Cum. Count Cum. Percent # --- ----- ------- -------- ----------- ------------- -# 1 M 10,401 52.0% 10,401 52.0% -# 2 F 9,599 48.0% 20,000 100.0% +# 1 M 10,468 52.3% 10,468 52.3% +# 2 F 9,532 47.7% 20,000 100.0%

So, we can draw at least two conclusions immediately. From a data scientists perspective, the data looks clean: only values M and F. From a researchers perspective: there are slightly more men. Nothing we didn’t already know.

The data is already quite clean, but we still need to transform some variables. The bacteria column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The mutate() function of the dplyr package makes this really easy:

data <- data %>%
@@ -437,14 +437,14 @@
 # Pasteurella multocida (no values changed)
 # Staphylococcus (no values changed)
 # Streptococcus groups A, B, C, G (no values changed)
-# Streptococcus pneumoniae (1,456 values changed)
+# Streptococcus pneumoniae (1,480 values changed)
 # Viridans group streptococci (no values changed)
 # 
 # EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-# Table 01: Intrinsic resistance in Enterobacteriaceae (1,287 values changed)
+# Table 01: Intrinsic resistance in Enterobacteriaceae (1,293 values changed)
 # Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria (no values changed)
 # Table 03: Intrinsic resistance in other Gram-negative bacteria (no values changed)
-# Table 04: Intrinsic resistance in Gram-positive bacteria (2,759 values changed)
+# Table 04: Intrinsic resistance in Gram-positive bacteria (2,772 values changed)
 # Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci (no values changed)
 # Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (no values changed)
 # Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no values changed)
@@ -452,24 +452,24 @@
 # Table 13: Interpretive rules for quinolones (no values changed)
 # 
 # Other rules
-# Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,330 values changed)
-# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (108 values changed)
+# Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,251 values changed)
+# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (117 values changed)
 # Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no values changed)
 # Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no values changed)
 # Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no values changed)
 # Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no values changed)
 # 
 # --------------------------------------------------------------------------
-# EUCAST rules affected 6,604 out of 20,000 rows, making a total of 7,940 edits
+# EUCAST rules affected 6,550 out of 20,000 rows, making a total of 7,913 edits
 # => added 0 test results
 # 
-# => changed 7,940 test results
-#    * 110 test results changed from S to I
-#    * 4,715 test results changed from S to R
-#    * 1,119 test results changed from I to S
-#    * 307 test results changed from I to R
-#    * 1,664 test results changed from R to S
-#    * 25 test results changed from R to I
+# => changed 7,913 test results
+#    * 111 test results changed from S to I
+#    * 4,763 test results changed from S to R
+#    * 1,086 test results changed from I to S
+#    * 349 test results changed from I to R
+#    * 1,585 test results changed from R to S
+#    * 19 test results changed from R to I
 # --------------------------------------------------------------------------
 # 
 # Use eucast_rules(..., verbose = TRUE) (on your original data) to get a data.frame with all specified edits instead.
@@ -497,7 +497,7 @@ # NOTE: Using column `bacteria` as input for `col_mo`. # NOTE: Using column `date` as input for `col_date`. # NOTE: Using column `patient_id` as input for `col_patient_id`. -# => Found 5,676 first isolates (28.4% of total)
+# => Found 5,610 first isolates (28.0% of total)

So only is suitable for resistance analysis! We can now filter on it with the filter() function, also from the dplyr package:

data_1st <- data %>% 
   filter(first == TRUE)
@@ -508,7 +508,7 @@

First weighted isolates

-

We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient M4, sorted on date:

+

We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient W2, sorted on date:

@@ -524,10 +524,10 @@ - - + + - + @@ -535,8 +535,8 @@ - - + + @@ -546,10 +546,10 @@ - - + + - + @@ -557,8 +557,8 @@ - - + + @@ -568,32 +568,32 @@ - - + + - + - - + + + + - - - - + + - + @@ -601,30 +601,30 @@ - - + + - + - - + + + - - + - - + + @@ -645,7 +645,7 @@ # NOTE: Using column `patient_id` as input for `col_patient_id`.# NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.# [Criterion] Inclusion based on key antibiotics, ignoring I. -# => Found 14,973 first weighted isolates (74.9% of total) +# => Found 15,032 first weighted isolates (75.2% of total)
isolate
12010-04-02M42010-02-15W2 B_ESCHR_COLRS S R S
22010-05-26M42010-05-10W2 B_ESCHR_COL S S
32010-07-15M42010-08-30W2 B_ESCHR_COLRS S S S
42010-09-11M42010-09-27W2 B_ESCHR_COL S S
52010-11-13M42010-10-28W2 B_ESCHR_COL RSR S S FALSE
62010-11-16M42010-12-01W2 B_ESCHR_COLSS R SSS FALSE
72011-01-03M42011-01-20W2 B_ESCHR_COLRS S S S
82011-03-16M42011-02-09W2 B_ESCHR_COL S SSR S FALSE
92011-04-21M42011-03-08W2 B_ESCHR_COLR S SSSR TRUE
102011-04-24M42011-04-14W2 B_ESCHR_COL S S
@@ -662,10 +662,10 @@ - - + + - + @@ -674,8 +674,8 @@ - - + + @@ -686,35 +686,35 @@ - - + + - + - + - - + + - + - - + + - + @@ -722,71 +722,71 @@ - - + + + + - - - + - - + + - + - + - - + + - + - - + + + - - + - - + + - +
isolate
12010-04-02M42010-02-15W2 B_ESCHR_COLRS S R S
22010-05-26M42010-05-10W2 B_ESCHR_COL S S
32010-07-15M42010-08-30W2 B_ESCHR_COLRS S S S FALSETRUEFALSE
42010-09-11M42010-09-27W2 B_ESCHR_COL S S S S FALSETRUEFALSE
52010-11-13M42010-10-28W2 B_ESCHR_COL RSR S S FALSE
62010-11-16M42010-12-01W2 B_ESCHR_COLSS R SSSFALSE FALSETRUE
72011-01-03M42011-01-20W2 B_ESCHR_COLRS S S S FALSEFALSETRUE
82011-03-16M42011-02-09W2 B_ESCHR_COL S SSR S FALSE TRUE
92011-04-21M42011-03-08W2 B_ESCHR_COLR S SSSR TRUE TRUE
102011-04-24M42011-04-14W2 B_ESCHR_COL S S S S FALSEFALSETRUE
-

Instead of 2, now 7 isolates are flagged. In total, of all isolates are marked ‘first weighted’ - more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.

+

Instead of 2, now 8 isolates are flagged. In total, of all isolates are marked ‘first weighted’ - more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.

As with filter_first_isolate(), there’s a shortcut for this new algorithm too:

data_1st <- data %>% 
   filter_first_weighted_isolate()
-

So we end up with 14,973 isolates for analysis.

+

So we end up with 15,032 isolates for analysis.

We can remove unneeded columns:

data_1st <- data_1st %>% 
   select(-c(first, keyab))
@@ -812,59 +812,43 @@ 3 -2015-08-15 -R1 -Hospital B -B_STRPT_PNE -S -S -S +2011-12-06 +I5 +Hospital C +B_KLBSL_PNE R -F -Gram-positive -Streptococcus +S +S +S +M +Gram-negative +Klebsiella pneumoniae TRUE 4 -2012-01-09 -X9 -Hospital D -B_STPHY_AUR -S -S -R -S -F -Gram-positive -Staphylococcus -aureus -TRUE - - -5 -2014-06-18 -Z7 +2011-03-10 +B9 Hospital D B_STRPT_PNE -S -S -S R -F +R +R +R +M Gram-positive Streptococcus pneumoniae TRUE - -6 -2015-02-18 -F4 -Hospital A + +5 +2010-06-27 +A2 +Hospital D B_ESCHR_COL -R +S S S S @@ -874,31 +858,47 @@ coli TRUE + +6 +2017-12-11 +F8 +Hospital A +B_STRPT_PNE +R +R +R +R +M +Gram-positive +Streptococcus +pneumoniae +TRUE + -7 -2010-11-14 -W5 -Hospital D -B_STPHY_AUR -S -S +8 +2014-06-01 +W7 +Hospital C +B_ESCHR_COL +R R S +S F -Gram-positive -Staphylococcus -aureus +Gram-negative +Escherichia +coli TRUE -8 -2010-12-25 -F4 -Hospital B +9 +2017-12-09 +A1 +Hospital C B_ESCHR_COL S S -S +R S M Gram-negative @@ -925,7 +925,7 @@
data_1st %>% freq(genus, species)

Frequency table

Class: character
-Length: 14,973 (of which NA: 0 = 0.00%)
+Length: 15,032 (of which NA: 0 = 0.00%)
Unique: 4

Shortest: 16
Longest: 24

@@ -942,33 +942,33 @@ Longest: 24

1 Escherichia coli -7,385 -49.3% -7,385 -49.3% +7,421 +49.4% +7,421 +49.4% 2 Staphylococcus aureus -3,709 -24.8% -11,094 -74.1% +3,771 +25.1% +11,192 +74.5% 3 Streptococcus pneumoniae -2,340 -15.6% -13,434 -89.7% +2,303 +15.3% +13,495 +89.8% 4 Klebsiella pneumoniae -1,539 -10.3% -14,973 +1,537 +10.2% +15,032 100.0% @@ -979,7 +979,7 @@ Longest: 24

Resistance percentages

The functions portion_S(), portion_SI(), portion_I(), portion_IR() and portion_R() can be used to determine the portion of a specific antimicrobial outcome. As per the EUCAST guideline of 2019, we calculate resistance as the portion of R (portion_R()) and susceptibility as the portion of S and I (portion_SI()). These functions can be used on their own:

data_1st %>% portion_R(AMX)
-# [1] 0.4646363
+# [1] 0.4640766

Or can be used in conjuction with group_by() and summarise(), both from the dplyr package:

data_1st %>% 
   group_by(hospital) %>% 
@@ -992,19 +992,19 @@ Longest: 24

Hospital A -0.4721851 +0.4620994 Hospital B -0.4554570 +0.4646182 Hospital C -0.4683715 +0.4689655 Hospital D -0.4663838 +0.4625253 @@ -1022,23 +1022,23 @@ Longest: 24

Hospital A -0.4721851 -4494 +0.4620994 +4525 Hospital B -0.4554570 -5186 +0.4646182 +5370 Hospital C -0.4683715 -2229 +0.4689655 +2175 Hospital D -0.4663838 -3064 +0.4625253 +2962 @@ -1058,27 +1058,27 @@ Longest: 24

Escherichia -0.9243060 -0.8958700 -0.9932295 +0.9217087 +0.8948929 +0.9932624 Klebsiella -0.8401559 -0.8992853 -0.9837557 +0.8217306 +0.9050098 +0.9915420 Staphylococcus -0.9280129 -0.9263953 -0.9967646 +0.9254840 +0.9252188 +0.9952267 Streptococcus -0.6303419 +0.6139818 0.0000000 -0.6303419 +0.6139818 diff --git a/docs/articles/AMR_files/figure-html/plot 1-1.png b/docs/articles/AMR_files/figure-html/plot 1-1.png index e466e422..36cc5fd5 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 1-1.png and b/docs/articles/AMR_files/figure-html/plot 1-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 3-1.png b/docs/articles/AMR_files/figure-html/plot 3-1.png index deb7c09f..b662703f 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 3-1.png and b/docs/articles/AMR_files/figure-html/plot 3-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 4-1.png b/docs/articles/AMR_files/figure-html/plot 4-1.png index c2732d0b..d0a9f7f7 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 4-1.png and b/docs/articles/AMR_files/figure-html/plot 4-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 5-1.png b/docs/articles/AMR_files/figure-html/plot 5-1.png index 04bc4bf0..1e167358 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 5-1.png and b/docs/articles/AMR_files/figure-html/plot 5-1.png differ diff --git a/docs/articles/EUCAST.html b/docs/articles/EUCAST.html index a9d2dded..8b51d9b5 100644 --- a/docs/articles/EUCAST.html +++ b/docs/articles/EUCAST.html @@ -40,7 +40,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029
@@ -185,7 +185,7 @@

How to apply EUCAST rules

Matthijs S. Berends

-

29 July 2019

+

08 August 2019

diff --git a/docs/articles/MDR.html b/docs/articles/MDR.html index 74ab07e9..01a9f159 100644 --- a/docs/articles/MDR.html +++ b/docs/articles/MDR.html @@ -40,7 +40,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 @@ -185,7 +185,7 @@

How to determine multi-drug resistance (MDR)

Matthijs S. Berends

-

07 August 2019

+

08 August 2019

@@ -228,19 +228,19 @@

The data set looks like this now:

head(my_TB_data)
 #   rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin
-# 1          R         R            S          S            I            S
-# 2          S         S            S          R            R            R
-# 3          S         S            S          S            R            R
-# 4          S         S            S          R            S            R
-# 5          S         R            R          R            R            R
-# 6          S         S            R          S            S            I
+# 1          S         S            S          S            R            S
+# 2          S         R            S          R            R            S
+# 3          R         R            S          S            S            S
+# 4          I         R            R          S            S            S
+# 5          R         I            R          S            R            R
+# 6          R         S            S          S            S            R
 #   kanamycin
 # 1         S
 # 2         R
-# 3         S
-# 4         S
-# 5         S
-# 6         S
+# 3 R +# 4 I +# 5 R +# 6 R

We can now add the interpretation of MDR-TB to our data set:

my_TB_data$mdr <- mdr_tb(my_TB_data)
 # NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.
@@ -272,32 +272,32 @@ Unique: 5

1 Mono-resistance -3271 +3270 65.4% -3271 +3270 65.4% 2 Negative -643 +645 12.9% -3914 +3915 78.3% 3 Multidrug resistance -582 -11.6% -4496 -89.9% +593 +11.9% +4508 +90.2% 4 Poly-resistance -287 -5.7% +275 +5.5% 4783 95.7% diff --git a/docs/articles/SPSS.html b/docs/articles/SPSS.html index 3364be69..3f3fbfee 100644 --- a/docs/articles/SPSS.html +++ b/docs/articles/SPSS.html @@ -40,7 +40,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029
@@ -185,7 +185,7 @@

How to import data from SPSS / SAS / Stata

Matthijs S. Berends

-

29 July 2019

+

08 August 2019

@@ -211,29 +211,33 @@
  • R is extremely flexible.

    -

    Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping, summarising and drawing plots is endless - with SPSS, SAS or Stata you are bound to their algorithms and styles. They may be a bit flexible, but you can probably never create that very specific publication-ready plot without using other (paid) software.

    +

    Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping and summarising data, or drawing plots, is endless - with SPSS, SAS or Stata you are bound to their algorithms and format styles. They may be a bit flexible, but you can probably never create that very specific publication-ready plot without using other (paid) software. If you sometimes write syntaxes in SPSS to run a complete analysis or to ‘automate’ some of your work, you could do this a lot less time in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS. Still, as working with any statistical package, you will have to have knowledge about what you are doing (statistically) and what you are willing to accomplish.

  • R can be easily automated.

    -

    Over the last years, R Markdown has really made an interesting development. With R Markdown, you can very easily produce reports, whether format has to be Word, PowerPoint, a website, a PDF document or just the raw data to Excel. It even allows the use of a reference file containing the layout style (e.g. fonts and colours) of your organisation. I use this a lot to generate weekly and monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like.

    +

    Over the last years, R Markdown has really made an interesting development. With R Markdown, you can very easily produce reports, whether the format has to be Word, PowerPoint, a website, a PDF document or just the raw data to Excel. It even allows the use of a reference file containing the layout style (e.g. fonts and colours) of your organisation. I use this a lot to generate weekly and monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like.

    For an even more professional environment, you could create Shiny apps: live manipulation of data using a custom made website. The webdesign knowledge needed (JavaScript, CSS, HTML) is almost zero.

  • R has a huge community.

    -

    Many R users just ask questions on websites like StackOverflow.com, the largest online community for programmers. At the time of writing, almost 300,000 R-related questions have already been asked on this platform (which covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.

    +

    Many R users just ask questions on websites like StackOverflow.com, the largest online community for programmers. At the time of writing, more than 300,000 R-related questions have already been asked on this platform (which covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.

  • R understands any data type, including SPSS/SAS/Stata.

    -

    And that’s not vice versa I’m afraid. You can import data from any source into R. From SPSS, SAS and Stata (link), from Minitab, Epi Info and EpiData (link), from Excel (link), from flat files like CSV, TXT or TSV (link), or directly from databases and datawarehouses from anywhere on the world (link). You can even scrape websites to download tables that are live on the internet (link) or get the results of an API call (link).

    +

    And that’s not vice versa I’m afraid. You can import data from any source into R. For example from SPSS, SAS and Stata (link), from Minitab, Epi Info and EpiData (link), from Excel (link), from flat files like CSV, TXT or TSV (link), or directly from databases and datawarehouses from anywhere on the world (link). You can even scrape websites to download tables that are live on the internet (link) or get the results of an API call and transform it into data in only one command (link).

    And the best part - you can export from R to most data formats as well. So you can import an SPSS file, do your analysis neatly in R and export the resulting tables to Excel files for sharing.

  • R is completely free and open-source.

    -

    No strings attached. It was created and is being maintained by volunteers who believe that (data) science should be open and publicly available to everybody. SPSS, SAS and Stata are quite expensive. IBM SPSS Staticstics only comes with subscriptions nowadays, varying between USD 1,300 and USD 8,500 per computer per year. SAS Analytics Pro costs around USD 10,000 per computer. Stata also has a business model with subscription fees, varying between USD 600 and USD 1,200 per computer per year, but lower prices come with a limitation of the number of variables you can work with.

    +

    No strings attached. It was created and is being maintained by volunteers who believe that (data) science should be open and publicly available to everybody. SPSS, SAS and Stata are quite expensive. IBM SPSS Staticstics only comes with subscriptions nowadays, varying between USD 1,300 and USD 8,500 per user per year. SAS Analytics Pro costs around USD 10,000 per computer. Stata also has a business model with subscription fees, varying between USD 600 and USD 2,800 per computer per year, but lower prices come with a limitation of the number of variables you can work with. And still they do not offer the above benefits of R.

    If you are working at a midsized or small company, you can save it tens of thousands of dollars by using R instead of e.g. SPSS - gaining even more functions and flexibility. And all R enthousiasts can do as much PR as they want (like I do here), because nobody is officially associated with or affiliated by R. It is really free.

  • +
  • +

    R is (nowadays) the preferred analysis software in academic papers.

    +

    At present, R is among the world most powerful statistical languages, and it is generally very popular in science (Bollmann et al., 2017). For all the above reasons, the number of references to R as an analysis method in academic papers is rising continuously and has even surpassed SPSS for academic use (Muenchen, 2014).

    +

    I believe that the thing with SPSS is, that it has always had a great user interface which is very easy to learn and use. Back when they developed it, they had very little competition, let alone from R. R didn’t even had a professional user interface until the last decade (called RStudio, see below). How people used R between the nineties and 2010 is almost completely incomparable to how R is being used now. The language itself has been restyled completely by volunteers who are dedicated professionals in the field of data science. SPSS was great when there was nothing else that could compete. But now in 2019, I don’t see any reason why SPSS would be of any better use than R.

    +
  • -

    If you sometimes write syntaxes in SPSS to run a complete analysis or to ‘automate’ some of your work, you should perhaps do this in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS. Still, as working with any statistical package, you will have to have knowledge about what you are doing (statistically) and what you are willing to accomplish.

    To demonstrate the first point:

    # not all values are valid MIC values:
     as.mic(0.125)
    @@ -251,10 +255,10 @@
     klebsiella_test <- data.frame(mo = "klebsiella", 
                                   amox = "S",
                                   stringsAsFactors = FALSE)
    -klebsiella_test
    +klebsiella_test # (our original data)
     #           mo amox
     # 1 klebsiella    S
    -eucast_rules(klebsiella_test, info = FALSE)
    +eucast_rules(klebsiella_test, info = FALSE) # (the edited data by EUCAST rules)
     #           mo amox
     # 1 klebsiella    R
     
    diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html
    index 41eb2e1e..55242463 100644
    --- a/docs/articles/WHONET.html
    +++ b/docs/articles/WHONET.html
    @@ -40,7 +40,7 @@
           
           
             AMR (for R)
    -        0.7.1.9027
    +        0.7.1.9029
           
         
    @@ -185,7 +185,7 @@

    How to work with WHONET data

    Matthijs S. Berends

    -

    07 August 2019

    +

    08 August 2019

    diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 0c5b69c9..2d2dbb5b 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -40,7 +40,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 @@ -185,7 +185,7 @@

    Benchmarks

    Matthijs S. Berends

    -

    29 July 2019

    +

    08 August 2019

    @@ -210,14 +210,14 @@ times = 10) print(S.aureus, unit = "ms", signif = 2) # Unit: milliseconds -# expr min lq mean median uq max neval -# as.mo("sau") 8.3 8.4 15.0 8.9 9.5 57.0 10 -# as.mo("stau") 30.0 31.0 42.0 32.0 48.0 110.0 10 -# as.mo("staaur") 8.3 8.4 10.0 8.5 8.9 25.0 10 -# as.mo("STAAUR") 8.1 8.4 10.0 8.4 9.1 24.0 10 -# as.mo("S. aureus") 23.0 23.0 29.0 24.0 38.0 45.0 10 -# as.mo("S. aureus") 22.0 22.0 24.0 23.0 24.0 38.0 10 -# as.mo("Staphylococcus aureus") 3.8 3.9 4.1 4.1 4.2 4.6 10
    +# expr min lq mean median uq max neval +# as.mo("sau") 8.4 8.5 12 9.1 10.0 27.0 10 +# as.mo("stau") 30.0 31.0 33 32.0 32.0 48.0 10 +# as.mo("staaur") 8.4 8.6 11 9.0 9.9 26.0 10 +# as.mo("STAAUR") 8.5 8.5 16 8.7 9.7 56.0 10 +# as.mo("S. aureus") 22.0 22.0 24 22.0 23.0 40.0 10 +# as.mo("S. aureus") 22.0 22.0 36 24.0 41.0 98.0 10 +# as.mo("Staphylococcus aureus") 3.9 4.0 4 4.0 4.1 4.3 10

    In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.

    To achieve this speed, the as.mo function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of Thermus islandicus (B_THERMS_ISL), a bug probably never found before in humans:

    T.islandicus <- microbenchmark(as.mo("theisl"),
    @@ -229,12 +229,12 @@
     print(T.islandicus, unit = "ms", signif = 2)
     # Unit: milliseconds
     #                         expr min  lq mean median  uq max neval
    -#              as.mo("theisl") 250 260  260    260 270 290    10
    -#              as.mo("THEISL") 250 260  270    260 270 320    10
    -#       as.mo("T. islandicus") 120 120  130    130 140 150    10
    -#      as.mo("T.  islandicus") 120 130  140    140 140 140    10
    -#  as.mo("Thermus islandicus")  45  46   55     56  62  67    10
    -

    That takes 8.8 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like Thermus islandicus) are almost fast - these are the most probable input from most data sets.

    +# as.mo("theisl") 260 270 280 280 290 310 10 +# as.mo("THEISL") 260 270 290 280 290 380 10 +# as.mo("T. islandicus") 130 140 150 150 150 160 10 +# as.mo("T. islandicus") 130 140 140 140 150 160 10 +# as.mo("Thermus islandicus") 47 50 58 62 65 68 10 +

    That takes 9.4 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like Thermus islandicus) are almost fast - these are the most probable input from most data sets.

    In the figure below, we compare Escherichia coli (which is very common) with Prevotella brevis (which is moderately common) and with Thermus islandicus (which is very uncommon):

    par(mar = c(5, 16, 4, 2)) # set more space for left margin text (16)
     
    @@ -280,8 +280,8 @@
     print(run_it, unit = "ms", signif = 3)
     # Unit: milliseconds
     #            expr min  lq mean median  uq max neval
    -#  mo_fullname(x) 586 611  623    619 638 671    10
    -

    So transforming 500,000 values (!!) of 50 unique values only takes 0.62 seconds (618 ms). You only lose time on your unique input values.

    +# mo_fullname(x) 625 649 665 666 677 724 10 +

    So transforming 500,000 values (!!) of 50 unique values only takes 0.67 seconds (666 ms). You only lose time on your unique input values.

    @@ -293,10 +293,10 @@ times = 10) print(run_it, unit = "ms", signif = 3) # Unit: milliseconds -# expr min lq mean median uq max neval -# A 6.350 6.600 7.050 6.870 7.35 8.37 10 -# B 21.300 21.500 25.300 22.200 22.70 48.20 10 -# C 0.624 0.753 0.804 0.783 0.87 1.01 10

    +# expr min lq mean median uq max neval +# A 6.440 6.65 6.880 6.840 7.15 7.48 10 +# B 22.400 22.90 26.200 23.600 25.20 44.00 10 +# C 0.762 0.81 0.848 0.818 0.87 1.10 10

    So going from mo_fullname("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0008 seconds - it doesn’t even start calculating if the result would be the same as the expected resulting value. That goes for all helper functions:

    run_it <- microbenchmark(A = mo_species("aureus"),
                              B = mo_genus("Staphylococcus"),
    @@ -310,14 +310,14 @@
     print(run_it, unit = "ms", signif = 3)
     # Unit: milliseconds
     #  expr   min    lq  mean median    uq   max neval
    -#     A 0.436 0.454 0.460  0.460 0.462 0.491    10
    -#     B 0.472 0.480 0.496  0.488 0.513 0.542    10
    -#     C 0.657 0.672 0.757  0.750 0.797 0.952    10
    -#     D 0.478 0.495 0.500  0.499 0.503 0.540    10
    -#     E 0.436 0.446 0.456  0.448 0.455 0.507    10
    -#     F 0.437 0.447 0.455  0.454 0.460 0.478    10
    -#     G 0.428 0.441 0.449  0.447 0.455 0.477    10
    -#     H 0.438 0.445 0.456  0.451 0.472 0.477    10
    +# A 0.437 0.456 0.499 0.482 0.560 0.607 10 +# B 0.474 0.484 0.534 0.509 0.588 0.627 10 +# C 0.621 0.712 0.799 0.812 0.829 1.020 10 +# D 0.469 0.482 0.534 0.513 0.595 0.654 10 +# E 0.415 0.434 0.493 0.459 0.557 0.678 10 +# F 0.458 0.523 0.538 0.546 0.554 0.601 10 +# G 0.416 0.438 0.484 0.450 0.563 0.621 10 +# H 0.420 0.434 0.491 0.448 0.577 0.620 10

    Of course, when running mo_phylum("Firmicutes") the function has zero knowledge about the actual microorganism, namely S. aureus. But since the result would be "Firmicutes" too, there is no point in calculating the result. And because this package ‘knows’ all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.

    @@ -343,14 +343,14 @@ times = 10) print(run_it, unit = "ms", signif = 4) # Unit: milliseconds -# expr min lq mean median uq max neval -# en 17.21 17.67 18.20 18.40 18.62 18.81 10 -# de 18.76 19.01 21.59 19.45 19.82 41.96 10 -# nl 24.15 24.57 29.11 25.67 26.49 45.25 10 -# es 18.31 19.02 19.33 19.37 19.93 20.09 10 -# it 18.96 19.27 23.48 19.58 20.91 41.27 10 -# fr 18.33 18.80 19.46 19.27 19.97 21.10 10 -# pt 18.89 19.50 20.54 19.70 20.36 27.83 10
    +# expr min lq mean median uq max neval +# en 17.02 17.26 17.89 17.85 18.50 18.84 10 +# de 18.28 18.65 22.91 18.84 19.67 41.64 10 +# nl 24.07 24.31 32.74 24.60 25.02 105.60 10 +# es 18.59 19.00 19.99 19.32 19.81 26.42 10 +# it 18.28 18.40 22.59 19.07 20.38 39.47 10 +# fr 18.34 18.70 21.48 19.37 20.83 34.67 10 +# pt 18.60 18.92 19.25 19.19 19.59 20.14 10

    Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.

    diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png index 95aa1508..88637bdf 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index 5d9b5448..8a032ca7 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.1.9029 + 0.7.1.9030 diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html index a2a5bee3..acea92ff 100644 --- a/docs/articles/resistance_predict.html +++ b/docs/articles/resistance_predict.html @@ -40,7 +40,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 @@ -185,7 +185,7 @@

    How to predict antimicrobial resistance

    Matthijs S. Berends

    -

    29 July 2019

    +

    08 August 2019

    @@ -212,15 +212,17 @@

    Our package contains a function resistance_predict(), which takes the same input as functions for other AMR analysis. Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.

    It is basically as easy as:

    # resistance prediction of piperacillin/tazobactam (TZP):
    -resistance_predict(tbl = septic_patients, col_date = "date", col_ab = "TZP")
    +resistance_predict(tbl = septic_patients, col_date = "date", col_ab = "TZP", model = "binomial")
     
     # or:
     septic_patients %>% 
    -  resistance_predict(col_ab = "TZP")
    -
    -# to bind it to object 'predict_TZP' for example:
    -predict_TZP <- septic_patients %>% 
    -  resistance_predict(col_ab = "TZP")
    + resistance_predict(col_ab = "TZP", + model "binomial") + +# to bind it to object 'predict_TZP' for example: +predict_TZP <- septic_patients %>% + resistance_predict(col_ab = "TZP", + model = "binomial")

    The function will look for a date column itself if col_date is not set.

    When running any of these commands, a summary of the regression model will be printed unless using resistance_predict(..., info = FALSE).

    # NOTE: Using column `date` as input for `col_date`.
    @@ -296,12 +298,12 @@
     

    Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:

    septic_patients %>%
       filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>%
    -  resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE) %>% 
    +  resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "binomial") %>% 
       ggplot_rsi_predict()
     # NOTE: Using column `date` as input for `col_date`.

    Vancomycin resistance could be 100% in ten years, but might also stay around 0%.

    -

    You can define the model with the model parameter. The default model is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.

    +

    You can define the model with the model parameter. The model chosen above is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.

    Valid values are:

    diff --git a/docs/authors.html b/docs/authors.html index 108bbd95..a10c8647 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.1.9029 + 0.7.1.9030 @@ -233,10 +233,6 @@

    Christian F. Luz. Author. ORCID

    -
  • -

    Erwin E. A. Hassing. Contributor. -

    -
  • Corinna Glasner. Author, thesis advisor. ORCID

    @@ -249,6 +245,18 @@

    Bhanu N. M. Sinha. Author, thesis advisor. ORCID

  • +
  • +

    Erwin E. A. Hassing. Contributor. +

    +
  • +
  • +

    Bart C. Meijer. Contributor. +

    +
  • +
  • +

    Dennis Souverein. Contributor. +

    +
  • diff --git a/docs/extra.js b/docs/extra.js index 69ef2e00..64dec4b3 100644 --- a/docs/extra.js +++ b/docs/extra.js @@ -80,6 +80,8 @@ $( document ).ready(function() { x = x.replace("Corinna", "Dr Corinna"); x = x.replace("Alex", "Prof Dr Alex"); x = x.replace("Bhanu", "Prof Dr Bhanu"); + x = x.replace("Bart", "Dr Bart"); + x = x.replace("Dennis", "Dr Dennis"); x = x.replace(/Author, thesis advisor/g, "Doctoral advisor"); x = x.replace(/Authors/g, "aut_plural"); x = x.replace(/Author, maintainer[.]?/g, ""); diff --git a/docs/index.html b/docs/index.html index f173c0ae..4223d3d4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 0.7.1.9029 + 0.7.1.9030 diff --git a/docs/news/index.html b/docs/news/index.html index 7f3360ae..59be947b 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.1.9029 + 0.7.1.9030 @@ -225,9 +225,9 @@ -
    +

    -AMR 0.7.1.9029 Unreleased +AMR 0.7.1.9030 Unreleased

    @@ -275,6 +275,7 @@
    • Added more informative errors and warnings to eucast_rules()
    • +
    • Fixed a bug in eucast_rules() where antibiotic columns would be read as lists instead of characters
    • Added tibble printing support for classes rsi, mic, ab and mo. When using tibbles containing antibiotic columns, values S will print in green, values I will print in yellow and values R will print in red:

      (run this on your own console, as this page does not support colour printing)
      @@ -307,6 +308,13 @@
       
    • Speed improvement for guess_ab_col() which is now 30 times faster for antibiotic abbreviations
    • Using factors as input for eucast_rules() now adds missing factors levels when the function changes antibiotic results

    +
    +

    +Other

    +
      +
    • Added Dr Bart Meijer and Dr Dennis Souverein as contributors
    • +
    +

    @@ -382,9 +390,9 @@
    -
    +

    -Other

    +Other
    • Fixed a note thrown by CRAN tests
    @@ -478,9 +486,9 @@ Please mo_shortname()
    where species would not be determined correctly

    -
    +

    -Other

    +Other
    -
    +

    -Other

    +Other
    • Updated licence text to emphasise GPL 2.0 and that this is an R package.
    @@ -851,9 +859,9 @@ Using as.mo(..., allow_uncertain = 3)

    Percentages will now will rounded more logically (e.g. in freq function)

    -
    +

    -Other

    +Other
    • New dependency on package crayon, to support formatted text in the console
    • Dependency tidyr is now mandatory (went to Import field) since portion_df and count_df rely on it
    • @@ -988,9 +996,9 @@ Using as.mo(..., allow_uncertain = 3)
    -
    +

    -Other

    +Other
    • More unit tests to ensure better integrity of functions
    @@ -1117,9 +1125,9 @@ Using as.mo(..., allow_uncertain = 3)Other small fixes
    -
    +

    -Other

    +Other
    • Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher
    -
    +

    -Other

    +Other
    • Expanded README.md with more examples
    • Added ORCID of authors to DESCRIPTION file
    • @@ -1218,7 +1226,7 @@ Using as.mo(..., allow_uncertain = 3)

      Contents

    diff --git a/docs/reference/AMR.html b/docs/reference/AMR.html index dea7cd8c..2e6fc49f 100644 --- a/docs/reference/AMR.html +++ b/docs/reference/AMR.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029
    diff --git a/docs/reference/WHOCC.html b/docs/reference/WHOCC.html index d96b2308..fc7bb100 100644 --- a/docs/reference/WHOCC.html +++ b/docs/reference/WHOCC.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029
    diff --git a/docs/reference/WHONET.html b/docs/reference/WHONET.html index 8366c8c8..a80047f6 100644 --- a/docs/reference/WHONET.html +++ b/docs/reference/WHONET.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029
    diff --git a/docs/reference/ab_property.html b/docs/reference/ab_property.html index 5972d988..dd12f3a0 100644 --- a/docs/reference/ab_property.html +++ b/docs/reference/ab_property.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029
    diff --git a/docs/reference/age.html b/docs/reference/age.html index 9c6d191b..2ddf8182 100644 --- a/docs/reference/age.html +++ b/docs/reference/age.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029
    diff --git a/docs/reference/age_groups.html b/docs/reference/age_groups.html index ef94ec08..c36dab44 100644 --- a/docs/reference/age_groups.html +++ b/docs/reference/age_groups.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029
    diff --git a/docs/reference/antibiotics.html b/docs/reference/antibiotics.html index 30422a28..23c41324 100644 --- a/docs/reference/antibiotics.html +++ b/docs/reference/antibiotics.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029
    diff --git a/docs/reference/as.ab.html b/docs/reference/as.ab.html index 3817e75e..1fca622b 100644 --- a/docs/reference/as.ab.html +++ b/docs/reference/as.ab.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029
    diff --git a/docs/reference/as.disk.html b/docs/reference/as.disk.html index 2b43b8e6..6fd4f23d 100644 --- a/docs/reference/as.disk.html +++ b/docs/reference/as.disk.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html index 4f64d520..614dac16 100644 --- a/docs/reference/as.mic.html +++ b/docs/reference/as.mic.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html index 86696e2f..6230a9e5 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index 38f9e150..20b0b9b1 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 diff --git a/docs/reference/atc_online.html b/docs/reference/atc_online.html index d9f7f5b6..b1fb6377 100644 --- a/docs/reference/atc_online.html +++ b/docs/reference/atc_online.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/availability.html b/docs/reference/availability.html index 0e232912..a6ef4b9f 100644 --- a/docs/reference/availability.html +++ b/docs/reference/availability.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/catalogue_of_life.html b/docs/reference/catalogue_of_life.html index 8e5b534c..8081bf20 100644 --- a/docs/reference/catalogue_of_life.html +++ b/docs/reference/catalogue_of_life.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/catalogue_of_life_version.html b/docs/reference/catalogue_of_life_version.html index 0aed698b..fc4a3205 100644 --- a/docs/reference/catalogue_of_life_version.html +++ b/docs/reference/catalogue_of_life_version.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 diff --git a/docs/reference/count.html b/docs/reference/count.html index ef9f9b5f..de022221 100644 --- a/docs/reference/count.html +++ b/docs/reference/count.html @@ -81,7 +81,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index 7d12efb3..b456f667 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 diff --git a/docs/reference/extended-functions.html b/docs/reference/extended-functions.html index 32543ef7..cc3eb68c 100644 --- a/docs/reference/extended-functions.html +++ b/docs/reference/extended-functions.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 diff --git a/docs/reference/filter_ab_class.html b/docs/reference/filter_ab_class.html index 3559e96b..3a558c84 100644 --- a/docs/reference/filter_ab_class.html +++ b/docs/reference/filter_ab_class.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 8db58b5b..e3a38f46 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/g.test.html b/docs/reference/g.test.html index a60d6dc2..b8b17aa1 100644 --- a/docs/reference/g.test.html +++ b/docs/reference/g.test.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html index 9769a94d..39f29e3b 100644 --- a/docs/reference/ggplot_rsi.html +++ b/docs/reference/ggplot_rsi.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/guess_ab_col.html b/docs/reference/guess_ab_col.html index 74c36996..8a7adc7f 100644 --- a/docs/reference/guess_ab_col.html +++ b/docs/reference/guess_ab_col.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/index.html b/docs/reference/index.html index 9f545ec7..5aec4a66 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.1.9029 + 0.7.1.9030 diff --git a/docs/reference/join.html b/docs/reference/join.html index 8f972cd6..848a28b8 100644 --- a/docs/reference/join.html +++ b/docs/reference/join.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index 22c913b5..0d035de8 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/kurtosis.html b/docs/reference/kurtosis.html index 977c8b5f..14afcaad 100644 --- a/docs/reference/kurtosis.html +++ b/docs/reference/kurtosis.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/like.html b/docs/reference/like.html index 899881a1..954e87c7 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index 3ae5d1da..7b210c76 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 diff --git a/docs/reference/microorganisms.codes.html b/docs/reference/microorganisms.codes.html index 541e64c0..b4f93f1b 100644 --- a/docs/reference/microorganisms.codes.html +++ b/docs/reference/microorganisms.codes.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/microorganisms.html b/docs/reference/microorganisms.html index 944fd721..5d570ca9 100644 --- a/docs/reference/microorganisms.html +++ b/docs/reference/microorganisms.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 diff --git a/docs/reference/microorganisms.old.html b/docs/reference/microorganisms.old.html index 2ceee01c..01144a20 100644 --- a/docs/reference/microorganisms.old.html +++ b/docs/reference/microorganisms.old.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9027 + 0.7.1.9029 diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index ff83d0d8..3c21207f 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/mo_source.html b/docs/reference/mo_source.html index 50d67bc8..cc7807e5 100644 --- a/docs/reference/mo_source.html +++ b/docs/reference/mo_source.html @@ -81,7 +81,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/p.symbol.html b/docs/reference/p.symbol.html index 35774dfc..81cb9696 100644 --- a/docs/reference/p.symbol.html +++ b/docs/reference/p.symbol.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/portion.html b/docs/reference/portion.html index a3433e1e..8a1f90db 100644 --- a/docs/reference/portion.html +++ b/docs/reference/portion.html @@ -81,7 +81,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/read.4D.html b/docs/reference/read.4D.html index 76d0263d..af293513 100644 --- a/docs/reference/read.4D.html +++ b/docs/reference/read.4D.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index eb063ac4..973418ef 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9029 + 0.7.1.9030 diff --git a/docs/reference/rsi_translation.html b/docs/reference/rsi_translation.html index ed09bc3a..ad463df0 100644 --- a/docs/reference/rsi_translation.html +++ b/docs/reference/rsi_translation.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/septic_patients.html b/docs/reference/septic_patients.html index 3442d8a4..eafd92bc 100644 --- a/docs/reference/septic_patients.html +++ b/docs/reference/septic_patients.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/skewness.html b/docs/reference/skewness.html index 120de23a..2b62506f 100644 --- a/docs/reference/skewness.html +++ b/docs/reference/skewness.html @@ -81,7 +81,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/docs/reference/translate.html b/docs/reference/translate.html index 8de2ba51..8d17761c 100644 --- a/docs/reference/translate.html +++ b/docs/reference/translate.html @@ -80,7 +80,7 @@ AMR (for R) - 0.7.1.9015 + 0.7.1.9029 diff --git a/pkgdown/extra.js b/pkgdown/extra.js index 69ef2e00..64dec4b3 100644 --- a/pkgdown/extra.js +++ b/pkgdown/extra.js @@ -80,6 +80,8 @@ $( document ).ready(function() { x = x.replace("Corinna", "Dr Corinna"); x = x.replace("Alex", "Prof Dr Alex"); x = x.replace("Bhanu", "Prof Dr Bhanu"); + x = x.replace("Bart", "Dr Bart"); + x = x.replace("Dennis", "Dr Dennis"); x = x.replace(/Author, thesis advisor/g, "Doctoral advisor"); x = x.replace(/Authors/g, "aut_plural"); x = x.replace(/Author, maintainer[.]?/g, ""); diff --git a/vignettes/SPSS.Rmd b/vignettes/SPSS.Rmd index 327d1227..7f5bf923 100755 --- a/vignettes/SPSS.Rmd +++ b/vignettes/SPSS.Rmd @@ -39,33 +39,36 @@ As said, SPSS is easier to learn than R. But SPSS, SAS and Stata come with major * **R is extremely flexible.** - Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping, summarising and drawing plots is endless - with SPSS, SAS or Stata you are bound to their algorithms and styles. They may be a bit flexible, but you can probably never create that very specific publication-ready plot without using other (paid) software. + Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping and summarising data, or drawing plots, is endless - with SPSS, SAS or Stata you are bound to their algorithms and format styles. They may be a bit flexible, but you can probably never create that very specific publication-ready plot without using other (paid) software. If you sometimes write syntaxes in SPSS to run a complete analysis or to 'automate' some of your work, you could do this a lot less time in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS. Still, as working with any statistical package, you will have to have knowledge about what you are doing (statistically) and what you are willing to accomplish. * **R can be easily automated.** - Over the last years, [R Markdown](https://rmarkdown.rstudio.com/) has really made an interesting development. With R Markdown, you can very easily produce reports, whether format has to be Word, PowerPoint, a website, a PDF document or just the raw data to Excel. It even allows the use of a reference file containing the layout style (e.g. fonts and colours) of your organisation. I use this a lot to generate weekly and monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like. + Over the last years, [R Markdown](https://rmarkdown.rstudio.com/) has really made an interesting development. With R Markdown, you can very easily produce reports, whether the format has to be Word, PowerPoint, a website, a PDF document or just the raw data to Excel. It even allows the use of a reference file containing the layout style (e.g. fonts and colours) of your organisation. I use this a lot to generate weekly and monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like. For an even more professional environment, you could create [Shiny apps](https://shiny.rstudio.com/): live manipulation of data using a custom made website. The webdesign knowledge needed (JavaScript, CSS, HTML) is almost *zero*. * **R has a huge community.** - Many R users just ask questions on websites like [StackOverflow.com](https://stackoverflow.com), the largest online community for programmers. At the time of writing, almost [300,000 R-related questions](https://stackoverflow.com/questions/tagged/r?sort=votes) have already been asked on this platform (which covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes. + Many R users just ask questions on websites like [StackOverflow.com](https://stackoverflow.com), the largest online community for programmers. At the time of writing, more than [300,000 R-related questions](https://stackoverflow.com/questions/tagged/r?sort=votes) have already been asked on this platform (which covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes. * **R understands any data type, including SPSS/SAS/Stata.** - And that's not vice versa I'm afraid. You can import data from any source into R. From SPSS, SAS and Stata ([link](https://haven.tidyverse.org/)), from Minitab, Epi Info and EpiData ([link](https://cran.r-project.org/package=foreign)), from Excel ([link](https://readxl.tidyverse.org/)), from flat files like CSV, TXT or TSV ([link](https://readr.tidyverse.org/)), or directly from databases and datawarehouses from anywhere on the world ([link](https://dbplyr.tidyverse.org/)). You can even scrape websites to download tables that are live on the internet ([link](https://github.com/hadley/rvest)) or get the results of an API call ([link](https://github.com/Rdatatable/data.table/wiki/Convenience-features-of-fread)). + And that's not vice versa I'm afraid. You can import data from any source into R. For example from SPSS, SAS and Stata ([link](https://haven.tidyverse.org/)), from Minitab, Epi Info and EpiData ([link](https://cran.r-project.org/package=foreign)), from Excel ([link](https://readxl.tidyverse.org/)), from flat files like CSV, TXT or TSV ([link](https://readr.tidyverse.org/)), or directly from databases and datawarehouses from anywhere on the world ([link](https://dbplyr.tidyverse.org/)). You can even scrape websites to download tables that are live on the internet ([link](https://github.com/hadley/rvest)) or get the results of an API call and transform it into data in only one command ([link](https://github.com/Rdatatable/data.table/wiki/Convenience-features-of-fread)). And the best part - you can export from R to most data formats as well. So you can import an SPSS file, do your analysis neatly in R and export the resulting tables to Excel files for sharing. * **R is completely free and open-source.** - No strings attached. It was created and is being maintained by volunteers who believe that (data) science should be open and publicly available to everybody. SPSS, SAS and Stata are quite expensive. IBM SPSS Staticstics only comes with subscriptions nowadays, varying [between USD 1,300 and USD 8,500](https://www.ibm.com/products/spss-statistics/pricing) per computer *per year*. SAS Analytics Pro costs [around USD 10,000](https://www.sas.com/store/products-solutions/sas-analytics-pro/prodPERSANL.html) per computer. Stata also has a business model with subscription fees, varying [between USD 600 and USD 1,200](https://www.stata.com/order/new/bus/single-user-licenses/dl/) per computer per year, but lower prices come with a limitation of the number of variables you can work with. + No strings attached. It was created and is being maintained by volunteers who believe that (data) science should be open and publicly available to everybody. SPSS, SAS and Stata are quite expensive. IBM SPSS Staticstics only comes with subscriptions nowadays, varying [between USD 1,300 and USD 8,500](https://www.ibm.com/products/spss-statistics/pricing) per user *per year*. SAS Analytics Pro costs [around USD 10,000](https://www.sas.com/store/products-solutions/sas-analytics-pro/prodPERSANL.html) per computer. Stata also has a business model with subscription fees, varying [between USD 600 and USD 2,800](https://www.stata.com/order/new/bus/single-user-licenses/dl/) per computer per year, but lower prices come with a limitation of the number of variables you can work with. And still they do not offer the above benefits of R. If you are working at a midsized or small company, you can save it tens of thousands of dollars by using R instead of e.g. SPSS - gaining even more functions and flexibility. And all R enthousiasts can do as much PR as they want (like I do here), because nobody is officially associated with or affiliated by R. It is really free. - - -If you sometimes write syntaxes in SPSS to run a complete analysis or to 'automate' some of your work, you should perhaps do this in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS. Still, as working with any statistical package, you will have to have knowledge about what you are doing (statistically) and what you are willing to accomplish. - + +* **R is (nowadays) the preferred analysis software in academic papers.** + + At present, R is among the world most powerful statistical languages, and it is generally very popular in science (Bollmann *et al.*, 2017). For all the above reasons, the number of references to R as an analysis method in academic papers [is rising continuously](https://r4stats.com/2014/08/20/r-passes-spss-in-scholarly-use-stata-growing-rapidly/) and has even surpassed SPSS for academic use (Muenchen, 2014). + + I believe that the thing with SPSS is, that it has always had a great user interface which is very easy to learn and use. Back when they developed it, they had very little competition, let alone from R. R didn't even had a professional user interface until the last decade (called RStudio, see below). How people used R between the nineties and 2010 is almost completely incomparable to how R is being used now. The language itself [has been restyled completely](https://www.tidyverse.org/packages/) by volunteers who are dedicated professionals in the field of data science. SPSS was great when there was nothing else that could compete. But now in `r max(2019, as.integer(format(Sys.Date(), "%Y")))`, I don't see any reason why SPSS would be of any better use than R. + To demonstrate the first point: ```{r, warning = FALSE, message = FALSE} @@ -80,8 +83,8 @@ mo_gramstain("E. coli") klebsiella_test <- data.frame(mo = "klebsiella", amox = "S", stringsAsFactors = FALSE) -klebsiella_test -eucast_rules(klebsiella_test, info = FALSE) +klebsiella_test # (our original data) +eucast_rules(klebsiella_test, info = FALSE) # (the edited data by EUCAST rules) # hundreds of trade names can be translated to a name, trade name or an ATC code: ab_name("floxapen") diff --git a/vignettes/resistance_predict.Rmd b/vignettes/resistance_predict.Rmd index 42dacde0..fd5c1bb5 100755 --- a/vignettes/resistance_predict.Rmd +++ b/vignettes/resistance_predict.Rmd @@ -42,15 +42,17 @@ Our package contains a function `resistance_predict()`, which takes the same inp It is basically as easy as: ```{r, eval = FALSE} # resistance prediction of piperacillin/tazobactam (TZP): -resistance_predict(tbl = septic_patients, col_date = "date", col_ab = "TZP") +resistance_predict(tbl = septic_patients, col_date = "date", col_ab = "TZP", model = "binomial") # or: septic_patients %>% - resistance_predict(col_ab = "TZP") + resistance_predict(col_ab = "TZP", + model "binomial") # to bind it to object 'predict_TZP' for example: predict_TZP <- septic_patients %>% - resistance_predict(col_ab = "TZP") + resistance_predict(col_ab = "TZP", + model = "binomial") ``` The function will look for a date column itself if `col_date` is not set. @@ -59,7 +61,7 @@ When running any of these commands, a summary of the regression model will be pr ```{r, echo = FALSE} predict_TZP <- septic_patients %>% - resistance_predict(col_ab = "TZP") + resistance_predict(col_ab = "TZP", model = "binomial") ``` This text is only a printed summary - the actual result (output) of the function is a `data.frame` containing for each year: the number of observations, the actual observed resistance, the estimated resistance and the standard error below and above the estimation: @@ -92,13 +94,13 @@ Resistance is not easily predicted; if we look at vancomycin resistance in Gram ```{r} septic_patients %>% filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>% - resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE) %>% + resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "binomial") %>% ggplot_rsi_predict() ``` Vancomycin resistance could be 100% in ten years, but might also stay around 0%. -You can define the model with the `model` parameter. The default model is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. +You can define the model with the `model` parameter. The model chosen above is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. Valid values are: