(v1.5.0.9018) fix unit tests

v1.8.2
parent cb404492b2
commit 2dd0656355
  1. 4
      DESCRIPTION
  2. 4
      NEWS.md
  3. 35
      R/first_isolate.R
  4. 13
      R/key_antibiotics.R
  5. 16
      R/mdro.R
  6. BIN
      data-raw/AMR_1.5.0.9018.tar.gz
  7. 2
      docs/404.html
  8. 2
      docs/LICENSE-text.html
  9. 462
      docs/articles/AMR.html
  10. BIN
      docs/articles/AMR_files/figure-html/plot 1-1.png
  11. BIN
      docs/articles/AMR_files/figure-html/plot 3-1.png
  12. BIN
      docs/articles/AMR_files/figure-html/plot 4-1.png
  13. BIN
      docs/articles/AMR_files/figure-html/plot 5-1.png
  14. 70
      docs/articles/MDR.html
  15. 2
      docs/articles/datasets.html
  16. 2
      docs/articles/index.html
  17. 2
      docs/articles/resistance_predict.html
  18. 2
      docs/articles/welcome_to_AMR.html
  19. 2
      docs/authors.html
  20. 2
      docs/index.html
  21. 103
      docs/news/index.html
  22. 2
      docs/pkgdown.yml
  23. 2
      docs/reference/index.html
  24. 2
      docs/survey.html

@ -1,6 +1,6 @@
Package: AMR
Version: 1.5.0.9017
Date: 2021-02-08
Version: 1.5.0.9018
Date: 2021-02-09
Title: Antimicrobial Resistance Data Analysis
Authors@R: c(
person(role = c("aut", "cre"),

@ -1,5 +1,5 @@
# AMR 1.5.0.9017
## <small>Last updated: 8 February 2021</small>
# AMR 1.5.0.9018
## <small>Last updated: 9 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.

@ -160,7 +160,12 @@ first_isolate <- function(x = NULL,
info = interactive(),
include_unknown = FALSE,
...) {
meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE) # also checks dimensions to be >0
if (is_null_or_grouped_tbl(x)) {
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
# is also fix for using a grouped df as input (a dot as first argument)
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
}
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
@ -184,12 +189,6 @@ first_isolate <- function(x = NULL,
meet_criteria(info, allow_class = "logical", has_length = 1)
meet_criteria(include_unknown, allow_class = "logical", has_length = 1)
if (is_null_or_grouped_tbl(x)) {
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
# is also fix for using a grouped df as input (a dot as first argument)
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
meet_criteria(x, allow_class = "data.frame")
}
# remove data.table, grouping from tibbles, etc.
x <- as.data.frame(x, stringsAsFactors = FALSE)
@ -512,16 +511,16 @@ filter_first_isolate <- function(x = NULL,
col_patient_id = NULL,
col_mo = NULL,
...) {
meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE)
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
if (is_null_or_grouped_tbl(x)) {
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
# is also fix for using a grouped df as input (a dot as first argument)
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
meet_criteria(x, allow_class = "data.frame")
}
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
subset(x, first_isolate(x = x,
col_date = col_date,
col_patient_id = col_patient_id,
@ -537,17 +536,17 @@ filter_first_weighted_isolate <- function(x = NULL,
col_mo = NULL,
col_keyantibiotics = NULL,
...) {
meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE)
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
if (is_null_or_grouped_tbl(x)) {
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
# is also fix for using a grouped df as input (a dot as first argument)
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
meet_criteria(x, allow_class = "data.frame")
}
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))
y <- x
if (is.null(col_keyantibiotics)) {
# first try to look for it

@ -130,7 +130,12 @@ key_antibiotics <- function(x = NULL,
GramNeg_6 = guess_ab_col(x, "meropenem"),
warnings = TRUE,
...) {
meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE)
if (is_null_or_grouped_tbl(x)) {
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
# is also fix for using a grouped df as input (a dot as first argument)
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
}
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
meet_criteria(universal_1, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
meet_criteria(universal_2, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
@ -152,12 +157,6 @@ key_antibiotics <- function(x = NULL,
meet_criteria(GramNeg_6, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE)
meet_criteria(warnings, allow_class = "logical", has_length = 1)
if (is_null_or_grouped_tbl(x)) {
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
# is also fix for using a grouped df as input (a dot as first argument)
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
meet_criteria(x, allow_class = "data.frame")
}
# force regular data.frame, not a tibble or data.table
x <- as.data.frame(x, stringsAsFactors = FALSE)

@ -155,7 +155,12 @@ mdro <- function(x = NULL,
verbose = FALSE,
only_rsi_columns = FALSE,
...) {
meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE)
if (is_null_or_grouped_tbl(x)) {
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
# is also fix for using a grouped df as input (a dot as first argument)
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
}
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
meet_criteria(guideline, allow_class = c("list", "character"), allow_NULL = TRUE)
if (!is.list(guideline)) {
meet_criteria(guideline, allow_class = "character", has_length = 1, allow_NULL = TRUE)
@ -214,14 +219,7 @@ mdro <- function(x = NULL,
}
}
}
if (is_null_or_grouped_tbl(x)) {
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
# is also fix for using a grouped df as input (a dot as first argument)
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x)
meet_criteria(x, allow_class = "data.frame")
}
# force regular data.frame, not a tibble or data.table
x <- as.data.frame(x, stringsAsFactors = FALSE)

@ -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.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9018</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.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9018</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.9014</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9018</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">02 February 2021</h4>
<h4 class="date">09 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 02 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 09 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-02</td>
<td align="center">2021-02-09</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-02</td>
<td align="center">2021-02-09</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-02</td>
<td align="center">2021-02-09</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@ -352,52 +352,52 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2012-05-30</td>
<td align="center">Q5</td>
<td align="center">2014-07-31</td>
<td align="center">F7</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">I</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">2012-10-04</td>
<td align="center">R8</td>
<td align="center">Hospital A</td>
<td align="center">2017-11-01</td>
<td align="center">W10</td>
<td align="center">Hospital B</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2015-02-19</td>
<td align="center">T6</td>
<td align="center">Hospital A</td>
<td align="center">2013-06-17</td>
<td align="center">T1</td>
<td align="center">Hospital D</td>
<td align="center">Klebsiella pneumoniae</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2015-07-17</td>
<td align="center">R4</td>
<td align="center">2012-12-13</td>
<td align="center">Q2</td>
<td align="center">Hospital C</td>
<td align="center">Streptococcus pneumoniae</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">F</td>
</tr>
<tr class="odd">
<td align="center">2011-01-13</td>
<td align="center">Q4</td>
<td align="center">2010-01-01</td>
<td align="center">O10</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">R</td>
@ -407,15 +407,15 @@
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2013-04-17</td>
<td align="center">A6</td>
<td align="center">Hospital C</td>
<td align="center">2010-07-24</td>
<td align="center">V5</td>
<td align="center">Hospital A</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">F</td>
</tr>
</tbody>
</table>
@ -449,16 +449,16 @@ Longest: 1</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">M</td>
<td align="right">10,232</td>
<td align="right">51.16%</td>
<td align="right">10,232</td>
<td align="right">51.16%</td>
<td align="right">10,335</td>
<td align="right">51.68%</td>
<td align="right">10,335</td>
<td align="right">51.68%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">F</td>
<td align="right">9,768</td>
<td align="right">48.84%</td>
<td align="right">9,665</td>
<td align="right">48.33%</td>
<td align="right">20,000</td>
<td align="right">100.00%</td>
</tr>
@ -503,7 +503,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.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>
<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>
<div class="sourceCode" id="cb16"><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>
@ -515,7 +515,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 J3, 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 N1, sorted on date:</p>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -531,30 +531,30 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-01-21</td>
<td align="center">J3</td>
<td align="center">2010-02-03</td>
<td align="center">N1</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-03-02</td>
<td align="center">J3</td>
<td align="center">2010-04-02</td>
<td align="center">N1</td>
<td align="center">B_ESCHR_COLI</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">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-08-02</td>
<td align="center">J3</td>
<td align="center">2010-06-23</td>
<td align="center">N1</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -564,19 +564,19 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-10-11</td>
<td align="center">J3</td>
<td align="center">2010-06-25</td>
<td align="center">N1</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">5</td>
<td align="center">2010-10-15</td>
<td align="center">J3</td>
<td align="center">2010-10-04</td>
<td align="center">N1</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -586,52 +586,52 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-10-23</td>
<td align="center">J3</td>
<td align="center">2010-10-11</td>
<td align="center">N1</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">R</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-11-25</td>
<td align="center">J3</td>
<td align="center">2010-10-29</td>
<td align="center">N1</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">FALSE</td>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-12-31</td>
<td align="center">J3</td>
<td align="center">2010-11-11</td>
<td align="center">N1</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="odd">
<td align="center">9</td>
<td align="center">2011-02-25</td>
<td align="center">J3</td>
<td align="center">2010-12-06</td>
<td align="center">N1</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">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-03-01</td>
<td align="center">J3</td>
<td align="center">2010-12-13</td>
<td align="center">N1</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
@ -641,7 +641,7 @@ Longest: 1</p>
</tr>
</tbody>
</table>
<p>Only 2 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p>
<p>Only 1 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p>
<p>If a column exists with a name like ‘key(…)ab’ the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:</p>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data</span> <span class="op">&lt;-</span> <span class="va">data</span> <span class="op">%&gt;%</span>
@ -665,11 +665,11 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-01-21</td>
<td align="center">J3</td>
<td align="center">2010-02-03</td>
<td align="center">N1</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
@ -677,44 +677,44 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-03-02</td>
<td align="center">J3</td>
<td align="center">2010-04-02</td>
<td align="center">N1</td>
<td align="center">B_ESCHR_COLI</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">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-08-02</td>
<td align="center">J3</td>
<td align="center">2010-06-23</td>
<td align="center">N1</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="even">
<td align="center">4</td>
<td align="center">2010-10-11</td>
<td align="center">J3</td>
<td align="center">2010-06-25</td>
<td align="center">N1</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>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-10-15</td>
<td align="center">J3</td>
<td align="center">2010-10-04</td>
<td align="center">N1</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -725,23 +725,23 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-10-23</td>
<td align="center">J3</td>
<td align="center">2010-10-11</td>
<td align="center">N1</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">R</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-11-25</td>
<td align="center">J3</td>
<td align="center">2010-10-29</td>
<td align="center">N1</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">FALSE</td>
@ -749,48 +749,48 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-12-31</td>
<td align="center">J3</td>
<td align="center">2010-11-11</td>
<td align="center">N1</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>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2011-02-25</td>
<td align="center">J3</td>
<td align="center">2010-12-06</td>
<td align="center">N1</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">TRUE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-03-01</td>
<td align="center">J3</td>
<td align="center">2010-12-13</td>
<td align="center">N1</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">FALSE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
</tbody>
</table>
<p>Instead of 2, now 9 isolates are flagged. In total, 78.5% of all isolates are marked ‘first weighted’ - 50.2% 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 1, now 8 isolates are flagged. In total, 78.2% of all isolates are marked ‘first weighted’ - 50.0% 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="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</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,707 isolates for analysis.</p>
<p>So we end up with 15,648 isolates for analysis.</p>
<p>We can remove unneeded columns:</p>
<div class="sourceCode" id="cb20"><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>
@ -800,6 +800,7 @@ 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%">
@ -815,6 +816,7 @@ Longest: 1</p>
<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>
@ -831,90 +833,96 @@ Longest: 1</p>
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2012-05-30</td>
<td align="center">Q5</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AURS</td>
<td align="left">4</td>
<td align="center">2012-12-13</td>
<td align="center">Q2</td>
<td align="center">Hospital C</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">R</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">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="center">2012-10-04</td>
<td align="center">R8</td>
<td align="center">Hospital A</td>
<td align="center">B_ESCHR_COLI</td>
<td align="left">5</td>
<td align="center">2010-01-01</td>
<td align="center">O10</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AURS</td>
<td align="center">R</td>
<td align="center">I</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">Escherichia</td>
<td align="center">coli</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">2015-02-19</td>
<td align="center">T6</td>
<td align="left">6</td>
<td align="center">2010-07-24</td>
<td align="center">V5</td>
<td align="center">Hospital A</td>
<td align="center">B_KLBSL_PNMN</td>
<td align="center">R</td>
<td align="center">B_STPHY_AURS</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>
<td align="center">Gram-negative</td>
<td align="center">Klebsiella</td>
<td align="center">pneumoniae</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2015-07-17</td>
<td align="center">R4</td>
<td align="center">Hospital C</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">R</td>
<td align="left">7</td>
<td align="center">2014-07-13</td>
<td align="center">G3</td>
<td align="center">Hospital B</td>
<td align="center">B_ESCHR_COLI</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">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">R</td>
<td align="center">M</td>
<td align="center">Gram-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">2011-01-13</td>
<td align="center">Q4</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AURS</td>
<td align="center">R</td>
<td align="left">8</td>
<td align="center">2013-07-06</td>
<td align="center">K1</td>
<td align="center">Hospital D</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">S</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">M</td>
<td align="center">Gram-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2013-04-17</td>
<td align="center">A6</td>
<td align="left">9</td>
<td align="center">2011-07-06</td>
<td align="center">X4</td>
<td align="center">Hospital C</td>
<td align="center">B_STPHY_AURS</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">S</td>
<td align="center">M</td>
<td align="center">F</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
@ -941,8 +949,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,707<br>
Available: 15,707 (100%, NA: 0 = 0%)<br>
Length: 15,648<br>
Available: 15,648 (100%, NA: 0 = 0%)<br>
Unique: 4</p>
<p>Shortest: 16<br>
Longest: 24</p>
@ -959,33 +967,33 @@ Longest: 24</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Escherichia coli</td>
<td align="right">7,921</td>
<td align="right">50.43%</td>
<td align="right">7,921</td>
<td align="right">50.43%</td>
<td align="right">7,846</td>
<td align="right">50.14%</td>
<td align="right">7,846</td>
<td align="right">50.14%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Staphylococcus aureus</td>
<td align="right">3,853</td>
<td align="right">24.53%</td>
<td align="right">11,774</td>
<td align="right">74.96%</td>
<td align="right">3,871</td>
<td align="right">24.74%</td>
<td align="right">11,717</td>
<td align="right">74.88%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td>
<td align="right">2,349</td>
<td align="right">14.96%</td>
<td align="right">14,123</td>
<td align="right">89.92%</td>
<td align="right">2,331</td>
<td align="right">14.90%</td>
<td align="right">14,048</td>
<td align="right">89.78%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td>
<td align="right">1,584</td>
<td align="right">10.08%</td>
<td align="right">15,707</td>
<td align="right">1,600</td>
<td align="right">10.22%</td>
<td align="right">15,648</td>
<td align="right">100.00%</td>
</tr>
</tbody>
@ -1012,50 +1020,50 @@ Longest: 24</p>
<tr class="odd">
<td align="center">E. coli</td>
<td align="center">AMX</td>
<td align="center">3775</td>
<td align="center">243</td>
<td align="center">3903</td>
<td align="center">7921</td>
<td align="center">3764</td>
<td align="center">263</td>
<td align="center">3819</td>
<td align="center">7846</td>
</tr>
<tr class="even">
<td align="center">E. coli</td>
<td align="center">AMC</td>
<td align="center">6223</td>
<td align="center">298</td>
<td align="center">1400</td>
<td align="center">7921</td>
<td align="center">6286</td>
<td align="center">255</td>
<td align="center">1305</td>
<td align="center">7846</td>
</tr>
<tr class="odd">
<td align="center">E. coli</td>
<td align="center">CIP</td>
<td align="center">5995</td>
<td align="center">5931</td>
<td align="center">0</td>
<td align="center">1926</td>
<td align="center">7921</td>
<td align="center">1915</td>
<td align="center">7846</td>
</tr>
<tr class="even">
<td align="center">E. coli</td>
<td align="center">GEN</td>
<td align="center">7173</td>
<td align="center">7043</td>
<td align="center">0</td>
<td align="center">748</td>
<td align="center">7921</td>
<td align="center">803</td>
<td align="center">7846</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">1584</td>
<td align="center">1584</td>
<td align="center">1600</td>
<td align="center">1600</td>
</tr>
<tr class="even">
<td align="center">K. pneumoniae</td>
<td align="center">AMC</td>
<td align="center">1230</td>
<td align="center">57</td>
<td align="center">297</td>
<td align="center">1584</td>
<td align="center">1270</td>
<td align="center">64</td>
<td align="center">266</td>
<td align="center">1600</td>
</tr>
</tbody>
</table>
@ -1078,34 +1086,34 @@ Longest: 24</p>
<tr class="odd">
<td align="center">E. coli</td>
<td align="center">CIP</td>
<td align="center">5995</td>
<td align="center">5931</td>
<td align="center">0</td>
<td align="center">1926</td>
<td align="center">7921</td>
<td align="center">1915</td>
<td align="center">7846</td>
</tr>
<tr class="even">
<td align="center">K. pneumoniae</td>
<td align="center">CIP</td>
<td align="center">1217</td>
<td align="center">1214</td>
<td align="center">0</td>
<td align="center">367</td>
<td align="center">1584</td>
<td align="center">386</td>
<td align="center">1600</td>
</tr>
<tr class="odd">
<td align="center">S. aureus</td>
<td align="center">CIP</td>
<td align="center">2930</td>
<td align="center">2965</td>
<td align="center">0</td>
<td align="center">923</td>
<td align="center">3853</td>
<td align="center">906</td>
<td align="center">3871</td>
</tr>
<tr class="even">
<td align="center">S. pneumoniae</td>
<td align="center">CIP</td>
<td align="center">1814</td>
<td align="center">1801</td>
<td align="center">0</td>
<td align="center">535</td>
<td align="center">2349</td>
<td align="center">530</td>
<td align="center">2331</td>
</tr>
</tbody>
</table>
@ -1118,7 +1126,7 @@ Longest: 24</p>
<p>As per the EUCAST guideline of 2019, we calculate resistance as the proportion of R (<code><a href="../reference/proportion.html">proportion_R()</a></code>, equal to <code><a href="../reference/proportion.html">resistance()</a></code>) and susceptibility as the proportion of S and I (<code><a href="../reference/proportion.html">proportion_SI()</a></code>, equal to <code><a href="../reference/proportion.html">susceptibility()</a></code>). These functions can be used on their own:</p>
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data_1st</span> <span class="op">%&gt;%</span> <span class="fu"><a href="../reference/proportion.html">resistance</a></span><span class="op">(</span><span class="va">AMX</span><span class="op">)</span>
<span class="co"># [1] 0.5358121</span></code></pre></div>
<span class="co"># [1] 0.5357873</span></code></pre></div>
<p>Or can be used in conjuction with <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code> and <code><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise()</a></code>, both from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">data_1st</span> <span class="op">%&gt;%</span>
@ -1133,19 +1141,19 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.5293870</td>
<td align="center">0.5376208</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.5388889</td>
<td align="center">0.5299270</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.5364048</td>
<td align="center">0.5439754</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.5397891</td>
<td align="center">0.5373087</td>
</tr>
</tbody>
</table>
@ -1165,23 +1173,23 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.5293870</td>
<td align="center">4747</td>
<td align="center">0.5376208</td>
<td align="center">4758</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.5388889</td>
<td align="center">5400</td>
<td align="center">0.5299270</td>
<td align="center">5480</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.5364048</td>
<td align="center">2431</td>
<td align="center">0.5439754</td>
<td align="center">2274</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.5397891</td>
<td align="center">3129</td>
<td align="center">0.5373087</td>