(v1.5.0.9027) website update

v1.8.2
parent 1737d56ae4
commit 41f94cde97
  1. 4
      DESCRIPTION
  2. 4
      NEWS.md
  3. 61
      R/ggplot_rsi.R
  4. 55
      R/plot.R
  5. 1
      R/zzz.R
  6. BIN
      data-raw/AMR_latest.tar.gz
  7. 2
      docs/404.html
  8. 2
      docs/LICENSE-text.html
  9. 515
      docs/articles/AMR.html
  10. BIN
      docs/articles/AMR_files/figure-html/disk_plots-1.png
  11. BIN
      docs/articles/AMR_files/figure-html/disk_plots_mo_ab-1.png
  12. BIN
      docs/articles/AMR_files/figure-html/mic_plots-1.png
  13. BIN
      docs/articles/AMR_files/figure-html/mic_plots-2.png
  14. BIN
      docs/articles/AMR_files/figure-html/mic_plots_mo_ab-1.png
  15. BIN
      docs/articles/AMR_files/figure-html/mic_plots_mo_ab-2.png
  16. BIN
      docs/articles/AMR_files/figure-html/plot 1-1.png
  17. BIN
      docs/articles/AMR_files/figure-html/plot 3-1.png
  18. BIN
      docs/articles/AMR_files/figure-html/plot 4-1.png
  19. BIN
      docs/articles/AMR_files/figure-html/plot 5-1.png
  20. BIN
      docs/articles/AMR_files/figure-html/unnamed-chunk-13-1.png
  21. BIN
      docs/articles/AMR_files/figure-html/unnamed-chunk-13-2.png
  22. BIN
      docs/articles/AMR_files/figure-html/unnamed-chunk-15-1.png
  23. BIN
      docs/articles/AMR_files/figure-html/unnamed-chunk-15-2.png
  24. BIN
      docs/articles/AMR_files/figure-html/unnamed-chunk-17-1.png
  25. BIN
      docs/articles/AMR_files/figure-html/unnamed-chunk-18-1.png
  26. 76
      docs/articles/benchmarks.html
  27. BIN
      docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png
  28. 2
      docs/articles/index.html
  29. 2
      docs/authors.html
  30. 5
      docs/extra.css
  31. 2
      docs/index.html
  32. 12
      docs/news/index.html
  33. 2
      docs/pkgdown.yml
  34. 2
      docs/reference/as.mic.html
  35. 16
      docs/reference/ggplot_rsi.html
  36. 4
      docs/reference/index.html
  37. 2
      docs/reference/like.html
  38. 20
      docs/reference/plot.html
  39. 2
      docs/reference/random.html
  40. 2
      docs/survey.html
  41. 14
      man/ggplot_rsi.Rd
  42. 18
      man/plot.Rd
  43. 5
      pkgdown/extra.css
  44. 1
      tests/testthat/test-rsi.R
  45. 25
      vignettes/AMR.Rmd

@ -1,6 +1,6 @@
Package: AMR
Version: 1.5.0.9026
Date: 2021-02-25
Version: 1.5.0.9027
Date: 2021-02-26
Title: Antimicrobial Resistance Data Analysis
Authors@R: c(
person(role = c("aut", "cre"),

@ -1,5 +1,5 @@
# AMR 1.5.0.9026
## <small>Last updated: 25 February 2021</small>
# AMR 1.5.0.9027
## <small>Last updated: 26 February 2021</small>
### New
* Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the `eucast_rules()` function and in `as.rsi()` to interpret MIC and disk diffusion values. This is now the default guideline in this package.

@ -36,8 +36,8 @@
#' @param facet variable to split plots by, either `"interpretation"` (default) or `"antibiotic"` or a grouping variable
#' @inheritParams proportion
#' @param nrow (when using `facet`) number of rows
#' @param colours a named vector with colours for the bars. The names must be one or more of: S, SI, I, IR, R or be `FALSE` for standard [ggplot2][ggplot2::ggplot()] colours. The default colours are colour-blind friendly, while maintaining the convention that e.g. 'susceptible' should be green and 'resistant' should be red.
#' @param aesthetics aesthetics to apply the colours to, defaults to "fill" but can also be "colour" or "both"
#' @param colours a named vactor with colour to be used for filling. The default colours are colour-blind friendly.
#' @param aesthetics aesthetics to apply the colours to, defaults to "fill" but can also be (a combination of) "alpha", "colour", "fill", "linetype", "shape" or "size"
#' @param datalabels show datalabels using [labels_rsi_count()]
#' @param datalabels.size size of the datalabels
#' @param datalabels.colour colour of the datalabels
@ -46,7 +46,7 @@
#' @param caption text to show as caption of the plot
#' @param x.title text to show as x axis description
#' @param y.title text to show as y axis description
#' @param ... other arguments passed on to [geom_rsi()]
#' @param ... other arguments passed on to [geom_rsi()] or, in case of [scale_rsi_colours()], named values to set colours. The default colours are colour-blind friendly, while maintaining the convention that e.g. 'susceptible' should be green and 'resistant' should be red. See *Examples*.
#' @details At default, the names of antibiotics will be shown on the plots using [ab_name()]. This can be set with the `translate_ab` argument. See [count_df()].
#'
#' ## The Functions
@ -56,7 +56,7 @@
#'
#' [scale_y_percent()] transforms the y axis to a 0 to 100% range using [ggplot2::scale_y_continuous()].
#'
#' [scale_rsi_colours()] sets colours to the bars: pastel blue for S, pastel turquoise for I and pastel red for R, using [ggplot2::scale_fill_manual()].
#' [scale_rsi_colours()] sets colours to the bars (green for S, yellow for I, and red for R). with multilingual support. The default colours are colour-blind friendly, while maintaining the convention that e.g. 'susceptible' should be green and 'resistant' should be red.
#'
#' [theme_rsi()] is a [ggplot2 theme][[ggplot2::theme()] with minimal distraction.
#'
@ -219,11 +219,6 @@ ggplot_rsi <- function(data,
theme_rsi()
if (fill == "interpretation") {
# set RSI colours
if (isFALSE(colours) & missing(datalabels.colour)) {
# set datalabel colour to middle grey
datalabels.colour <- "grey50"
}
p <- p + scale_rsi_colours(colours = colours)
}
@ -362,28 +357,50 @@ scale_y_percent <- function(breaks = seq(0, 1, 0.1), limits = NULL) {
#' @rdname ggplot_rsi
#' @export
scale_rsi_colours <- function(colours = c(S = "#3CAEA3",
SI = "#3CAEA3",
I = "#F6D55C",
IR = "#ED553B",
R = "#ED553B"),
scale_rsi_colours <- function(...,
aesthetics = "fill") {
stop_ifnot_installed("ggplot2")
meet_criteria(colours, allow_class = c("character", "logical"))
meet_criteria(aesthetics, allow_class = c("character"), has_length = c(1, 2), is_in = c("colour", "color", "fill", "both"))
meet_criteria(aesthetics, allow_class = c("character"), has_length = c(1, 2), is_in = c("alpha", "colour", "color", "fill", "linetype", "shape", "size"))
if (!identical(colours, FALSE)) {
if ("both" %in% aesthetics) {
aesthetics <- c("colour", "fill")
}
# behaviour until AMR pkg v1.5.0 and also when coming from ggplot_rsi()
if ("colours" %in% names(list(...))) {
original_cols <- c(S = "#3CAEA3",
SI = "#3CAEA3",
I = "#F6D55C",
IR = "#ED553B",
R = "#ED553B")
colours <- replace(original_cols, names(colours), colours)
ggplot2::scale_fill_manual(values = colours, aesthetics = aesthetics)
colours <- replace(original_cols, names(list(...)$colours), list(...)$colours)
return(ggplot2::scale_fill_manual(values = colours))
}
if (identical(unlist(list(...)), FALSE)) {
return(invisible())
}
names_susceptible <- c("S", "SI", "IS", "S+I", "I+S", "susceptible",
unique(translations_file[which(translations_file$pattern == "susceptible"),
"replacement", drop = TRUE]))
names_incr_exposure <- c("I", "intermediate", "increased exposure", "incr. exposure",
unique(translations_file[which(translations_file$pattern == "intermediate"),
"replacement", drop = TRUE]))
names_resistant <- c("R", "IR", "RI", "R+I", "I+R", "resistant",
unique(translations_file[which(translations_file$pattern == "resistant"),
"replacement", drop = TRUE]))
susceptible <- rep("#3CAEA3", length(names_susceptible))
names(susceptible) <- names_susceptible
incr_exposure <- rep("#F6D55C", length(names_incr_exposure))
names(incr_exposure) <- names_incr_exposure
resistant <- rep("#ED553B", length(names_resistant))
names(resistant) <- names_resistant
original_cols = c(susceptible, incr_exposure, resistant)
dots <- c(...)
# replace S, I, R as colours: scale_rsi_colours(mydatavalue = "S")
dots[dots == "S"] <- "#3CAEA3"
dots[dots == "I"] <- "#F6D55C"
dots[dots == "R"] <- "#ED553B"
colours <- replace(original_cols, names(dots), dots)
ggplot2::scale_discrete_manual(aesthetics = aesthetics, values = colours)
}
#' @rdname ggplot_rsi

@ -50,9 +50,11 @@
#' @examples
#' some_mic_values <- random_mic(size = 100)
#' some_disk_values <- random_disk(size = 100, mo = "Escherichia coli", ab = "cipro")
#' some_rsi_values <- random_rsi(50, prob_RSI = c(0.30, 0.55, 0.05))
#'
#' plot(some_mic_values)
#' plot(some_disk_values)
#' plot(some_rsi_values)
#'
#' # when providing the microorganism and antibiotic, colours will show interpretations:
#' plot(some_mic_values, mo = "S. aureus", ab = "ampicillin")
@ -61,6 +63,7 @@
#' if (require("ggplot2")) {
#' ggplot(some_mic_values)
#' ggplot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
#' ggplot(some_rsi_values)
#' }
NULL
@ -229,7 +232,7 @@ ggplot.mic <- function(data,
name = NULL)
} else {
p <- p +
ggplot2::geom_col(aes(x = mic, y = count))
ggplot2::geom_col(ggplot2::aes(x = mic, y = count))
}
p +
@ -242,7 +245,7 @@ ggplot.mic <- function(data,
#' @importFrom graphics barplot axis mtext legend
#' @rdname plot
plot.disk <- function(x,
main = paste("Disk zones values of", deparse(substitute(x))),
main = paste("Disk zones of", deparse(substitute(x))),
ylab = "Frequency",
xlab = "Disk diffusion diameter (mm)",
mo = NULL,
@ -315,7 +318,7 @@ plot.disk <- function(x,
#' @export
#' @noRd
barplot.disk <- function(height,
main = paste("Disk zones values of", deparse(substitute(height))),
main = paste("Disk zones of", deparse(substitute(height))),
ylab = "Frequency",
xlab = "Disk diffusion diameter (mm)",
mo = NULL,
@ -350,7 +353,7 @@ barplot.disk <- function(height,
# will be exported using s3_register() in R/zzz.R
ggplot.disk <- function(data,
mapping = NULL,
title = paste("Disk zones values of", deparse(substitute(data))),
title = paste("Disk zones of", deparse(substitute(data))),
ylab = "Frequency",
xlab = "Disk diffusion diameter (mm)",
mo = NULL,
@ -395,7 +398,7 @@ ggplot.disk <- function(data,
if (any(colours_RSI %in% cols_sub$cols)) {
p <- p +
ggplot2::geom_col(aes(x = disk, y = count, fill = cols)) +
ggplot2::geom_col(ggplot2::aes(x = disk, y = count, fill = cols)) +
ggplot2::scale_fill_manual(values = c("Resistant" = colours_RSI[1],
"Susceptible" = colours_RSI[2],
"Incr. exposure" = colours_RSI[3],
@ -403,7 +406,7 @@ ggplot.disk <- function(data,
name = NULL)
} else {
p <- p +
ggplot2::geom_col(aes(x = disk, y = count))
ggplot2::geom_col(ggplot2::aes(x = disk, y = count))
}
p +
@ -514,7 +517,7 @@ plot.rsi <- function(x,
stringsAsFactors = FALSE)
}
data$x <- factor(data$x, levels = c("R", "S", "I"), ordered = TRUE)
data$x <- factor(data$x, levels = c("S", "I", "R"), ordered = TRUE)
ymax <- pm_if_else(max(data$s) > 95, 105, 100)
@ -558,7 +561,7 @@ barplot.rsi <- function(height,
main <- gsub(" +", " ", paste0(main, collapse = " "))
x <- table(height)
x <- x[c(3, 1, 2)]
x <- x[c(1, 2, 3)]
barplot(x,
col = colours_RSI,
xlab = xlab,
@ -567,3 +570,39 @@ barplot.rsi <- function(height,
axes = FALSE)
axis(2, seq(0, max(x)))
}
#' @method ggplot rsi
#' @rdname plot
# will be exported using s3_register() in R/zzz.R
ggplot.rsi <- function(data,
mapping = NULL,
title = paste("Resistance Overview of", deparse(substitute(data))),
xlab = "Antimicrobial Interpretation",
ylab = "Frequency",
colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
...) {
stop_ifnot_installed("ggplot2")
meet_criteria(title, allow_class = "character")
meet_criteria(ylab, allow_class = "character", has_length = 1)
meet_criteria(xlab, allow_class = "character", has_length = 1)
meet_criteria(colours_RSI, allow_class = "character", has_length = c(1, 3))
if (length(colours_RSI) == 1) {
colours_RSI <- rep(colours_RSI, 3)
}
df <- as.data.frame(table(data), stringsAsFactors = TRUE)
colnames(df) <- c("rsi", "count")
if (!is.null(mapping)) {
p <- ggplot2::ggplot(df, mapping = mapping)
} else {
p <- ggplot2::ggplot(df)
}
p +
ggplot2::geom_col(ggplot2::aes(x = rsi, y = count, fill = rsi)) +
ggplot2::scale_fill_manual(values = c("R" = colours_RSI[1],
"S" = colours_RSI[2],
"I" = colours_RSI[3])) +
ggplot2::labs(title = title, x = xlab, y = ylab) +
ggplot2::theme(legend.position = "none")
}

@ -50,6 +50,7 @@ pkg_env$mo_failed <- character(0)
s3_register("skimr::get_skimmers", "rsi")
s3_register("skimr::get_skimmers", "mic")
s3_register("skimr::get_skimmers", "disk")
s3_register("ggplot2::ggplot", "rsi")
s3_register("ggplot2::ggplot", "mic")
s3_register("ggplot2::ggplot", "disk")

Binary file not shown.

@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9027</span>
</span>
</div>

@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9027</span>
</span>
</div>

@ -39,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9027</span>
</span>
</div>
@ -193,7 +193,7 @@
<h1 data-toc-skip>How to conduct AMR data analysis</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">25 February 2021</h4>
<h4 class="date">26 February 2021</h4>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/AMR.Rmd"><code>vignettes/AMR.Rmd</code></a></small>
<div class="hidden name"><code>AMR.Rmd</code></div>
@ -202,7 +202,7 @@
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 25 February 2021.</p>
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 26 February 2021.</p>
<div id="introduction" class="section level1">
<h1 class="hasAnchor">
<a href="#introduction" class="anchor"></a>Introduction</h1>
@ -233,21 +233,21 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2021-02-25</td>
<td align="center">2021-02-26</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
<td align="center">2021-02-25</td>
<td align="center">2021-02-26</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
</tr>
<tr class="odd">
<td align="center">2021-02-25</td>
<td align="center">2021-02-26</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@ -344,65 +344,65 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2014-07-28</td>
<td align="center">B5</td>
<td align="center">2012-05-31</td>
<td align="center">J3</td>
<td align="center">Hospital A</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2017-09-25</td>
<td align="center">X1</td>
<td align="center">2012-11-27</td>
<td align="center">R2</td>
<td align="center">Hospital B</td>
<td align="center">Klebsiella pneumoniae</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2017-04-18</td>
<td align="center">V9</td>
<td align="center">Hospital D</td>
<td align="center">Klebsiella pneumoniae</td>
<td align="center">I</td>
<td align="center">2017-07-10</td>
<td align="center">B1</td>
<td align="center">Hospital B</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2016-06-06</td>
<td align="center">Z2</td>
<td align="center">Hospital A</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">2013-11-18</td>
<td align="center">B1</td>
<td align="center">Hospital B</td>
<td align="center">Klebsiella pneumoniae</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2016-01-08</td>
<td align="center">V6</td>
<td align="center">Hospital C</td>
<td align="center">Klebsiella pneumoniae</td>
<td align="center">S</td>
<td align="center">2016-07-29</td>
<td align="center">O3</td>
<td align="center">Hospital A</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2015-03-14</td>
<td align="center">Y2</td>
<td align="center">2016-09-06</td>
<td align="center">U3</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
@ -441,16 +441,16 @@ Longest: 1</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">M</td>
<td align="right">10,502</td>
<td align="right">52.51%</td>
<td align="right">10,502</td>
<td align="right">52.51%</td>
<td align="right">10,409</td>
<td align="right">52.05%</td>
<td align="right">10,409</td>
<td align="right">52.05%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">F</td>
<td align="right">9,498</td>
<td align="right">47.49%</td>
<td align="right">9,591</td>
<td align="right">47.96%</td>
<td align="right">20,000</td>
<td align="right">100.00%</td>
</tr>
@ -495,7 +495,7 @@ Longest: 1</p>
<span class="co"># NOTE: Using column 'bacteria' as input for `col_mo`.</span>
<span class="co"># NOTE: Using column 'date' as input for `col_date`.</span>
<span class="co"># NOTE: Using column 'patient_id' as input for `col_patient_id`.</span></code></pre></div>
<p>So only 28.3% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
<p>So only 28.4% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data_1st</span> <span class="op">&lt;-</span> <span class="va">data</span> <span class="op">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="va">first</span> <span class="op">==</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
@ -507,7 +507,7 @@ Longest: 1</p>
<div id="first-weighted-isolates" class="section level2">
<h2 class="hasAnchor">
<a href="#first-weighted-isolates" class="anchor"></a>First <em>weighted</em> isolates</h2>
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all <em>E. coli</em> isolates of patient B7, sorted on date:</p>
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all <em>E. coli</em> isolates of patient Y5, sorted on date:</p>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -523,10 +523,10 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-03-16</td>
<td align="center">B7</td>
<td align="center">2010-01-04</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
@ -534,8 +534,8 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-05-03</td>
<td align="center">B7</td>
<td align="center">2010-01-13</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -545,19 +545,19 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-05-16</td>
<td align="center">B7</td>
<td align="center">2010-04-23</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-07-25</td>
<td align="center">B7</td>
<td align="center">2010-06-13</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -567,19 +567,19 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-07-26</td>
<td align="center">B7</td>
<td align="center">2010-09-02</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-10-14</td>
<td align="center">B7</td>
<td align="center">2010-11-12</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -589,10 +589,10 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-12-24</td>
<td align="center">B7</td>
<td align="center">2010-11-14</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
@ -600,33 +600,33 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2011-02-27</td>
<td align="center">B7</td>
<td align="center">2010-12-31</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2011-09-02</td>
<td align="center">B7</td>
<td align="center">2011-03-02</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-11-08</td>
<td align="center">B7</td>
<td align="center">2011-06-09</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">I</td>
<td align="center">I</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
@ -657,10 +657,10 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-03-16</td>
<td align="center">B7</td>
<td align="center">2010-01-04</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
@ -669,8 +669,8 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-05-03</td>
<td align="center">B7</td>
<td align="center">2010-01-13</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -681,20 +681,20 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-05-16</td>
<td align="center">B7</td>
<td align="center">2010-04-23</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-07-25</td>
<td align="center">B7</td>
<td align="center">2010-06-13</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -705,47 +705,47 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-07-26</td>
<td align="center">B7</td>
<td align="center">2010-09-02</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-10-14</td>
<td align="center">B7</td>
<td align="center">2010-11-12</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-12-24</td>
<td align="center">B7</td>
<td align="center">2010-11-14</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2011-02-27</td>
<td align="center">B7</td>
<td align="center">2010-12-31</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
@ -753,36 +753,36 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2011-09-02</td>
<td align="center">B7</td>
<td align="center">2011-03-02</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-11-08</td>
<td align="center">B7</td>
<td align="center">2011-06-09</td>
<td align="center">Y5</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">I</td>
<td align="center">I</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
</tbody>
</table>
<p>Instead of 2, now 10 isolates are flagged. In total, 79.1% of all isolates are marked ‘first weighted’ - 50.8% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
<p>Instead of 2, now 5 isolates are flagged. In total, 78.5% of all isolates are marked ‘first weighted’ - 50.1% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
<p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, there’s a shortcut for this new algorithm too:</p>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data_1st</span> <span class="op">&lt;-</span> <span class="va">data</span> <span class="op">%&gt;%</span>
<span class="fu"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
<p>So we end up with 15,821 isolates for analysis.</p>
<p>So we end up with 15,695 isolates for analysis.</p>
<p>We can remove unneeded columns:</p>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data_1st</span> <span class="op">&lt;-</span> <span class="va">data_1st</span> <span class="op">%&gt;%</span>
@ -792,7 +792,6 @@ Longest: 1</p>
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span><span class="op">(</span><span class="va">data_1st</span><span class="op">)</span></code></pre></div>
<table class="table">
<colgroup>
<col width="2%">
<col width="8%">
<col width="8%">
<col width="8%">
@ -802,13 +801,12 @@ Longest: 1</p>
<col width="3%">
<col width="3%">
<col width="5%">
<col width="10%">
<col width="11%">
<col width="11%">
<col width="8%">
<col width="11%">
</colgroup>
<thead><tr class="header">
<th align="left"></th>
<th align="center">date</th>
<th align="center">patient_id</th>
<th align="center">hospital</th>
@ -825,13 +823,12 @@ Longest: 1</p>
</tr></thead>
<tbody>
<tr class="odd">
<td align="left">1</td>
<td align="center">2014-07-28</td>
<td align="center">B5</td>
<td align="center">2012-05-31</td>
<td align="center">J3</td>
<td align="center">Hospital A</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
@ -841,14 +838,13 @@ Longest: 1</p>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="center">2017-09-25</td>
<td align="center">X1</td>
<td align="center">2012-11-27</td>
<td align="center">R2</td>
<td align="center">Hospital B</td>
<td align="center">B_KLBSL_PNMN</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">Gram-negative</td>
@ -857,67 +853,63 @@ Longest: 1</p>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="center">2017-04-18</td>
<td align="center">V9</td>
<td align="center">Hospital D</td>
<td align="center">B_KLBSL_PNMN</td>
<td align="center">R</td>
<td align="center">2017-07-10</td>
<td align="center">B1</td>
<td align="center">Hospital B</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">Gram-negative</td>
<td align="center">Klebsiella</td>
<td align="center">R</td>
<td align="center">M</td>
<td align="center">Gram-positive</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="left">5</td>
<td align="center">2016-01-08</td>
<td align="center">V6</td>
<td align="center">Hospital C</td>
<td align="center">2013-11-18</td>
<td align="center">B1</td>
<td align="center">Hospital B</td>
<td align="center">B_KLBSL_PNMN</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">M</td>
<td align="center">Gram-negative</td>
<td align="center">Klebsiella</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="left">6</td>
<td align="center">2015-03-14</td>
<td align="center">Y2</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AURS</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">2016-07-29</td>
<td align="center">O3</td>
<td align="center">Hospital A</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">F</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="left">7</td>
<td align="center">2014-12-23</td>
<td align="center">G8</td>
<td align="center">Hospital A</td>
<td align="center">B_STPHY_AURS</td>
<td align="center">S</td>
<td align="center">2016-09-06</td>
<td align="center">U3</td>
<td align="center">Hospital B</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">R</td>
<td align="center">F</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
</tbody>
@ -941,8 +933,8 @@ Longest: 1</p>
<code class="sourceCode R"><span class="va">data_1st</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span><span class="op">(</span><span class="va">genus</span>, <span class="va">species</span><span class="op">)</span></code></pre></div>
<p><strong>Frequency table</strong></p>
<p>Class: character<br>
Length: 15,821<br>
Available: 15,821 (100%, NA: 0 = 0%)<br>
Length: 15,695<br>
Available: 15,695 (100%, NA: 0 = 0%)<br>
Unique: 4</p>
<p>Shortest: 16<br>
Longest: 24</p>
@ -959,33 +951,33 @@ Longest: 24</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Escherichia coli</td>
<td align="right">7,994</td>
<td align="right">50.53%</td>
<td align="right">7,994</td>
<td align="right">50.53%</td>
<td align="right">7,829</td>
<td align="right">49.88%</td>
<td align="right">7,829</td>
<td align="right">49.88%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Staphylococcus aureus</td>
<td align="right">3,923</td>
<td align="right">24.80%</td>
<td align="right">11,917</td>
<td align="right">3,992</td>
<td align="right">25.43%</td>
<td align="right">11,821</td>
<td align="right">75.32%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td>
<td align="right">2,321</td>
<td align="right">14.67%</td>
<td align="right">14,238</td>
<td align="right">89.99%</td>
<td align="right">2,287</td>
<td align="right">14.57%</td>
<td align="right">14,108</td>
<td align="right">89.89%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td>
<td align="right">1,583</td>
<td align="right">10.01%</td>
<td align="right">15,821</td>
<td align="right">1,587</td>
<td align="right">10.11%</td>
<td align="right">15,695</td>
<td align="right">100.00%</td>
</tr>
</tbody>
@ -1012,50 +1004,50 @@ Longest: 24</p>
<tr class="odd">
<td align="center">E. coli</td>
<td align="center">AMX</td>
<td align="center">3815</td>
<td align="center">239</td>
<td align="center">3940</td>
<td align="center">7994</td>
<td align="center">3743</td>
<td align="center">231</td>
<td align="center">3855</td>
<td align="center">7829</td>
</tr>
<tr class="even">
<td align="center">E. coli</td>
<td align="center">AMC</td>
<td align="center">6289</td>
<td align="center">304</td>
<td align="center">1401</td>
<td align="center">7994</td>
<td align="center">6200</td>
<td align="center">283</td>
<td align="center">1346</td>
<td align="center">7829</td>
</tr>
<tr class="odd">
<td align="center">E. coli</td>
<td align="center">CIP</td>
<td align="center">6086</td>
<td align="center">5941</td>
<td align="center">0</td>
<td align="center">1908</td>
<td align="center">7994</td>
<td align="center">1888</td>
<td align="center">7829</td>
</tr>
<tr class="even">
<td align="center">E. coli</td>
<td align="center">GEN</td>
<td align="center">7158</td>
<td align="center">7047</td>
<td align="center">0</td>
<td align="center">836</td>
<td align="center">7994</td>
<td align="center">782</td>
<td align="center">7829</td>
</tr>
<tr class="odd">
<td align="center">K. pneumoniae</td>
<td align="center">AMX</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1583</td>
<td align="center">1583</td>
<td align="center">1587</td>
<td align="center">1587</td>
</tr>
<tr class="even">
<td align="center">K. pneumoniae</td>
<td align="center">AMC</td>
<td align="center">1224</td>
<td align="center">57</td>
<td align="center">302</td>
<td align="center">1583</td>
<td align="center">1242</td>
<td align="center">65</td>
<td align="center">280</td>
<td align="center">1587</td>
</tr>
</tbody>
</table>
@ -1078,34 +1070,34 @@ Longest: 24</p>
<tr class="odd">
<td align="center">E. coli</td>
<td align="center">CIP</td>
<td align="center">6086</td>
<td align="center">5941</td>
<td align="center">0</td>
<td align="center">1908</td>
<td align="center">7994</td>
<td align="center">1888</td>
<td align="center">7829</td>
</tr>
<tr class="even">
<td align="center">K. pneumoniae</td>
<td align="center">CIP</td>
<td align="center">1215</td>
<td align="center">1218</td>
<td a