Browse Source

as.mo improvements

new-mo-algorithm
parent
commit
f16a152d06
  1. 16
      R/mo.R
  2. 497
      docs/articles/AMR.html
  3. BIN
      docs/articles/AMR_files/figure-html/plot 1-1.png
  4. BIN
      docs/articles/AMR_files/figure-html/plot 3-1.png
  5. BIN
      docs/articles/AMR_files/figure-html/plot 4-1.png
  6. BIN
      docs/articles/AMR_files/figure-html/plot 5-1.png
  7. 1
      docs/articles/WHONET.html
  8. 104
      docs/articles/benchmarks.html
  9. BIN
      docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png
  10. 8
      docs/articles/resistance_predict.html
  11. 2
      vignettes/benchmarks.Rmd

16
R/mo.R

@ -210,6 +210,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, @@ -210,6 +210,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
uncertainties <- character(0)
failures <- character(0)
x_input <- x
# already strip leading and trailing spaces
x <- trimws(x, which = "both")
# only check the uniques, which is way faster
x <- unique(x)
@ -218,6 +219,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, @@ -218,6 +219,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
# conversion of old MO codes from v0.5.0 (ITIS) to later versions (Catalogue of Life)
if (any(x %like% "^[BFP]_[A-Z]{3,7}")) {
print("is any")
leftpart <- gsub("^([BFP]_[A-Z]{3,7}).*", "\\1", x)
if (any(leftpart %in% names(mo_codes_v0.5.0))) {
rightpart <- gsub("^[BFP]_[A-Z]{3,7}(.*)", "\\1", x)
@ -241,8 +243,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, @@ -241,8 +243,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
)
}
# all empty
if (all(identical(trimws(x_input), "") | is.na(x_input))) {
# all empty
if (property == "mo") {
return(structure(rep(NA_character_, length(x_input)), class = "mo"))
} else {
@ -264,6 +266,11 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, @@ -264,6 +266,11 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
# existing mo codes when not looking for property "mo", like mo_genus("B_ESCHR_COL")
x <- microorganismsDT[data.table(mo = x), on = "mo", ..property][[1]]
} else if (all(x %in% microorganismsDT[prevalence == 1, "fullname"][[1]])) {
# we need special treatment for prevalent full names, they are likely!
# e.g. as.mo("Staphylococcus aureus")
x <- microorganismsDT[prevalence == 1][data.table(fullname = x), on = "fullname", ..property][[1]]
} else if (all(toupper(x) %in% microorganisms.codes[, "code"])) {
# commonly used MO codes
y <- as.data.table(microorganisms.codes)[data.table(code = toupper(x)), on = "code", ]
@ -271,7 +278,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, @@ -271,7 +278,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
} else if (!all(x %in% microorganismsDT[[property]])) {
x_backup <- x # trimws(x, which = "both")
x_backup <- x
# remove spp and species
x <- trimws(gsub(" +(spp.?|ssp.?|sp.? |ss ?.?|subsp.?|subspecies|biovar |serovar |species)", " ", x_backup, ignore.case = TRUE), which = "both")
@ -517,11 +524,6 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, @@ -517,11 +524,6 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
return(found[1L])
}
# found <- data_to_check[mo == toupper(a.x_backup), ..property][[1]]
# # is a valid mo
# if (length(found) > 0) {
# return(found[1L])
# }
found <- data_to_check[tolower(fullname) == tolower(c.x_trimmed_without_group), ..property][[1]]
if (length(found) > 0) {
return(found[1L])

497
docs/articles/AMR.html

@ -327,70 +327,70 @@ @@ -327,70 +327,70 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2011-09-14</td>
<td align="center">N3</td>
<td align="center">Hospital B</td>
<td align="center">2017-09-14</td>
<td align="center">X8</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">S</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2011-01-09</td>
<td align="center">I3</td>
<td align="center">Hospital A</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">2011-10-29</td>
<td align="center">H5</td>
<td align="center">Hospital D</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">S</td>
<td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2015-06-02</td>
<td align="center">E8</td>
<td align="center">Hospital A</td>
<td align="center">2013-02-03</td>
<td align="center">D7</td>
<td align="center">Hospital D</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">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2011-02-06</td>
<td align="center">S1</td>
<td align="center">Hospital D</td>
<td align="center">2013-01-14</td>
<td align="center">U1</td>
<td align="center">Hospital C</td>
<td align="center">Escherichia 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">R</td>
<td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2010-01-27</td>
<td align="center">N7</td>
<td align="center">Hospital C</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">2010-02-23</td>
<td align="center">O7</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">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2017-08-11</td>
<td align="center">U3</td>
<td align="center">Hospital B</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">2010-09-26</td>
<td align="center">E6</td>
<td align="center">Hospital D</td>
<td align="center">Klebsiella pneumoniae</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">M</td>
</tr>
</tbody>
</table>
@ -411,8 +411,8 @@ @@ -411,8 +411,8 @@
#&gt;
#&gt; Item Count Percent Cum. Count Cum. Percent
#&gt; --- ----- ------- -------- ----------- -------------
#&gt; 1 M 10,364 51.8% 10,364 51.8%
#&gt; 2 F 9,636 48.2% 20,000 100.0%</code></pre>
#&gt; 1 M 10,391 52.0% 10,391 52.0%
#&gt; 2 F 9,609 48.0% 20,000 100.0%</code></pre>
<p>So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values <code>M</code> and <code>F</code>. From a researcher perspective: there are slightly more men. Nothing we didn’t already know.</p>
<p>The data is already quite clean, but we still need to transform some variables. The <code>bacteria</code> 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 <code><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate()</a></code> function of the <code>dplyr</code> package makes this really easy:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" title="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span></a>
@ -423,48 +423,50 @@ @@ -423,48 +423,50 @@
<p>Finally, we will apply <a href="http://www.eucast.org/expert_rules_and_intrinsic_resistance/">EUCAST rules</a> on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function can also apply additional rules, like forcing <help title="ATC: J01CA01">ampicillin</help> = R when <help title="ATC: J01CR02">amoxicillin/clavulanic acid</help> = R.</p>
<p>Because the amoxicillin (column <code>amox</code>) and amoxicillin/clavulanic acid (column <code>amcl</code>) in our data were generated randomly, some rows will undoubtedly contain amox = S and amcl = R, which is technically impossible. The <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> fixes this:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb14-1" title="1">data &lt;-<span class="st"> </span><span class="kw"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(data, <span class="dt">col_mo =</span> <span class="st">"bacteria"</span>)</a>
<a class="sourceLine" id="cb14-2" title="2"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-3" title="3"><span class="co">#&gt; Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)</span></a>
<a class="sourceLine" id="cb14-2" title="2"><span class="co">#&gt; [1] "is any"</span></a>
<a class="sourceLine" id="cb14-3" title="3"><span class="co">#&gt; [1] "is any"</span></a>
<a class="sourceLine" id="cb14-4" title="4"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-5" title="5"><span class="co">#&gt; EUCAST Clinical Breakpoints (v9.0, 2019)</span></a>
<a class="sourceLine" id="cb14-6" title="6"><span class="co">#&gt; Enterobacteriales (Order) (no changes)</span></a>
<a class="sourceLine" id="cb14-7" title="7"><span class="co">#&gt; Staphylococcus (no changes)</span></a>
<a class="sourceLine" id="cb14-8" title="8"><span class="co">#&gt; Enterococcus (no changes)</span></a>
<a class="sourceLine" id="cb14-9" title="9"><span class="co">#&gt; Streptococcus groups A, B, C, G (no changes)</span></a>
<a class="sourceLine" id="cb14-10" title="10"><span class="co">#&gt; Streptococcus pneumoniae (no changes)</span></a>
<a class="sourceLine" id="cb14-11" title="11"><span class="co">#&gt; Viridans group streptococci (no changes)</span></a>
<a class="sourceLine" id="cb14-12" title="12"><span class="co">#&gt; Haemophilus influenzae (no changes)</span></a>
<a class="sourceLine" id="cb14-13" title="13"><span class="co">#&gt; Moraxella catarrhalis (no changes)</span></a>
<a class="sourceLine" id="cb14-14" title="14"><span class="co">#&gt; Anaerobic Gram positives (no changes)</span></a>
<a class="sourceLine" id="cb14-15" title="15"><span class="co">#&gt; Anaerobic Gram negatives (no changes)</span></a>
<a class="sourceLine" id="cb14-16" title="16"><span class="co">#&gt; Pasteurella multocida (no changes)</span></a>
<a class="sourceLine" id="cb14-17" title="17"><span class="co">#&gt; Campylobacter jejuni and C. coli (no changes)</span></a>
<a class="sourceLine" id="cb14-18" title="18"><span class="co">#&gt; Aerococcus sanguinicola and A. urinae (no changes)</span></a>
<a class="sourceLine" id="cb14-19" title="19"><span class="co">#&gt; Kingella kingae (no changes)</span></a>
<a class="sourceLine" id="cb14-20" title="20"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-21" title="21"><span class="co">#&gt; EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a>
<a class="sourceLine" id="cb14-22" title="22"><span class="co">#&gt; Table 1: Intrinsic resistance in Enterobacteriaceae (1334 changes)</span></a>
<a class="sourceLine" id="cb14-23" title="23"><span class="co">#&gt; Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-24" title="24"><span class="co">#&gt; Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-25" title="25"><span class="co">#&gt; Table 4: Intrinsic resistance in Gram-positive bacteria (2731 changes)</span></a>
<a class="sourceLine" id="cb14-26" title="26"><span class="co">#&gt; Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a>
<a class="sourceLine" id="cb14-27" title="27"><span class="co">#&gt; Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a>
<a class="sourceLine" id="cb14-28" title="28"><span class="co">#&gt; Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-29" title="29"><span class="co">#&gt; Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)</span></a>
<a class="sourceLine" id="cb14-30" title="30"><span class="co">#&gt; Table 12: Interpretive rules for aminoglycosides (no changes)</span></a>
<a class="sourceLine" id="cb14-31" title="31"><span class="co">#&gt; Table 13: Interpretive rules for quinolones (no changes)</span></a>
<a class="sourceLine" id="cb14-32" title="32"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-33" title="33"><span class="co">#&gt; Other rules</span></a>
<a class="sourceLine" id="cb14-34" title="34"><span class="co">#&gt; Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (no changes)</span></a>
<a class="sourceLine" id="cb14-35" title="35"><span class="co">#&gt; Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span></a>
<a class="sourceLine" id="cb14-36" title="36"><span class="co">#&gt; Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span></a>
<a class="sourceLine" id="cb14-37" title="37"><span class="co">#&gt; Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (no changes)</span></a>
<a class="sourceLine" id="cb14-38" title="38"><span class="co">#&gt; Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a>
<a class="sourceLine" id="cb14-39" title="39"><span class="co">#&gt; Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a>
<a class="sourceLine" id="cb14-40" title="40"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-41" title="41"><span class="co">#&gt; =&gt; EUCAST rules affected 7,419 out of 20,000 rows</span></a>
<a class="sourceLine" id="cb14-42" title="42"><span class="co">#&gt; -&gt; added 0 test results</span></a>
<a class="sourceLine" id="cb14-43" title="43"><span class="co">#&gt; -&gt; changed 4,065 test results (0 to S; 0 to I; 4,065 to R)</span></a></code></pre></div>
<a class="sourceLine" id="cb14-5" title="5"><span class="co">#&gt; Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)</span></a>
<a class="sourceLine" id="cb14-6" title="6"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-7" title="7"><span class="co">#&gt; EUCAST Clinical Breakpoints (v9.0, 2019)</span></a>
<a class="sourceLine" id="cb14-8" title="8"><span class="co">#&gt; Enterobacteriales (Order) (no changes)</span></a>
<a class="sourceLine" id="cb14-9" title="9"><span class="co">#&gt; Staphylococcus (no changes)</span></a>
<a class="sourceLine" id="cb14-10" title="10"><span class="co">#&gt; Enterococcus (no changes)</span></a>
<a class="sourceLine" id="cb14-11" title="11"><span class="co">#&gt; Streptococcus groups A, B, C, G (no changes)</span></a>
<a class="sourceLine" id="cb14-12" title="12"><span class="co">#&gt; Streptococcus pneumoniae (no changes)</span></a>
<a class="sourceLine" id="cb14-13" title="13"><span class="co">#&gt; Viridans group streptococci (no changes)</span></a>
<a class="sourceLine" id="cb14-14" title="14"><span class="co">#&gt; Haemophilus influenzae (no changes)</span></a>
<a class="sourceLine" id="cb14-15" title="15"><span class="co">#&gt; Moraxella catarrhalis (no changes)</span></a>
<a class="sourceLine" id="cb14-16" title="16"><span class="co">#&gt; Anaerobic Gram positives (no changes)</span></a>
<a class="sourceLine" id="cb14-17" title="17"><span class="co">#&gt; Anaerobic Gram negatives (no changes)</span></a>
<a class="sourceLine" id="cb14-18" title="18"><span class="co">#&gt; Pasteurella multocida (no changes)</span></a>
<a class="sourceLine" id="cb14-19" title="19"><span class="co">#&gt; Campylobacter jejuni and C. coli (no changes)</span></a>
<a class="sourceLine" id="cb14-20" title="20"><span class="co">#&gt; Aerococcus sanguinicola and A. urinae (no changes)</span></a>
<a class="sourceLine" id="cb14-21" title="21"><span class="co">#&gt; Kingella kingae (no changes)</span></a>
<a class="sourceLine" id="cb14-22" title="22"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-23" title="23"><span class="co">#&gt; EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a>
<a class="sourceLine" id="cb14-24" title="24"><span class="co">#&gt; Table 1: Intrinsic resistance in Enterobacteriaceae (1230 changes)</span></a>
<a class="sourceLine" id="cb14-25" title="25"><span class="co">#&gt; Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-26" title="26"><span class="co">#&gt; Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-27" title="27"><span class="co">#&gt; Table 4: Intrinsic resistance in Gram-positive bacteria (2700 changes)</span></a>
<a class="sourceLine" id="cb14-28" title="28"><span class="co">#&gt; Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a>
<a class="sourceLine" id="cb14-29" title="29"><span class="co">#&gt; Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a>
<a class="sourceLine" id="cb14-30" title="30"><span class="co">#&gt; Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-31" title="31"><span class="co">#&gt; Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)</span></a>
<a class="sourceLine" id="cb14-32" title="32"><span class="co">#&gt; Table 12: Interpretive rules for aminoglycosides (no changes)</span></a>
<a class="sourceLine" id="cb14-33" title="33"><span class="co">#&gt; Table 13: Interpretive rules for quinolones (no changes)</span></a>
<a class="sourceLine" id="cb14-34" title="34"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-35" title="35"><span class="co">#&gt; Other rules</span></a>
<a class="sourceLine" id="cb14-36" title="36"><span class="co">#&gt; Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (no changes)</span></a>
<a class="sourceLine" id="cb14-37" title="37"><span class="co">#&gt; Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span></a>
<a class="sourceLine" id="cb14-38" title="38"><span class="co">#&gt; Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span></a>
<a class="sourceLine" id="cb14-39" title="39"><span class="co">#&gt; Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (no changes)</span></a>
<a class="sourceLine" id="cb14-40" title="40"><span class="co">#&gt; Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a>
<a class="sourceLine" id="cb14-41" title="41"><span class="co">#&gt; Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a>
<a class="sourceLine" id="cb14-42" title="42"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-43" title="43"><span class="co">#&gt; =&gt; EUCAST rules affected 7,267 out of 20,000 rows</span></a>
<a class="sourceLine" id="cb14-44" title="44"><span class="co">#&gt; -&gt; added 0 test results</span></a>
<a class="sourceLine" id="cb14-45" title="45"><span class="co">#&gt; -&gt; changed 3,930 test results (0 to S; 0 to I; 3,930 to R)</span></a></code></pre></div>
</div>
<div id="adding-new-variables" class="section level1">
<h1 class="hasAnchor">
@ -473,7 +475,11 @@ @@ -473,7 +475,11 @@
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb15-1" title="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb15-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">gramstain =</span> <span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(bacteria),</a>
<a class="sourceLine" id="cb15-3" title="3"> <span class="dt">genus =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(bacteria),</a>
<a class="sourceLine" id="cb15-4" title="4"> <span class="dt">species =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(bacteria))</a></code></pre></div>
<a class="sourceLine" id="cb15-4" title="4"> <span class="dt">species =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(bacteria))</a>
<a class="sourceLine" id="cb15-5" title="5"><span class="co">#&gt; [1] "is any"</span></a>
<a class="sourceLine" id="cb15-6" title="6"><span class="co">#&gt; [1] "is any"</span></a>
<a class="sourceLine" id="cb15-7" title="7"><span class="co">#&gt; [1] "is any"</span></a>
<a class="sourceLine" id="cb15-8" title="8"><span class="co">#&gt; [1] "is any"</span></a></code></pre></div>
<div id="first-isolates" class="section level2">
<h2 class="hasAnchor">
<a href="#first-isolates" class="anchor"></a>First isolates</h2>
@ -489,7 +495,7 @@ @@ -489,7 +495,7 @@
<a class="sourceLine" id="cb16-3" title="3"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
<a class="sourceLine" id="cb16-4" title="4"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
<a class="sourceLine" id="cb16-5" title="5"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
<a class="sourceLine" id="cb16-6" title="6"><span class="co">#&gt; =&gt; Found 5,667 first isolates (28.3% of total)</span></a></code></pre></div>
<a class="sourceLine" id="cb16-6" title="6"><span class="co">#&gt; =&gt; Found 5,663 first isolates (28.3% of total)</span></a></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>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" title="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb17-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first <span class="op">==</span><span class="st"> </span><span class="ot">TRUE</span>)</a></code></pre></div>
@ -516,8 +522,8 @@ @@ -516,8 +522,8 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-02-08</td>
<td align="center">H1</td>
<td align="center">2010-04-19</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -527,41 +533,41 @@ @@ -527,41 +533,41 @@
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-04-06</td>
<td align="center">H1</td>
<td align="center">2010-08-08</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">I</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-04-25</td>
<td align="center">H1</td>
<td align="center">2010-10-31</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">I</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-10-05</td>
<td align="center">H1</td>
<td align="center">2010-11-11</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-11-09</td>
<td align="center">H1</td>
<td align="center">2011-04-04</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -571,58 +577,58 @@ @@ -571,58 +577,58 @@
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-11-23</td>
<td align="center">H1</td>
<td align="center">2011-05-22</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-12-26</td>
<td align="center">H1</td>
<td align="center">2011-08-15</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">R</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">2011-01-01</td>
<td align="center">H1</td>
<td align="center">2011-08-20</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</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">9</td>
<td align="center">2011-01-21</td>
<td align="center">H1</td>
<td align="center">2011-08-25</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</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">FALSE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-02-28</td>
<td align="center">H1</td>
<td align="center">2011-12-16</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</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">TRUE</td>
<td align="center">FALSE</td>
</tr>
</tbody>
</table>
@ -632,12 +638,14 @@ @@ -632,12 +638,14 @@
<a class="sourceLine" id="cb19-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">keyab =</span> <span class="kw"><a href="../reference/key_antibiotics.html">key_antibiotics</a></span>(.)) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb19-3" title="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">first_weighted =</span> <span class="kw"><a href="../reference/first_isolate.html">first_isolate</a></span>(.))</a>
<a class="sourceLine" id="cb19-4" title="4"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
<a class="sourceLine" id="cb19-5" title="5"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
<a class="sourceLine" id="cb19-6" title="6"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
<a class="sourceLine" id="cb19-7" title="7"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
<a class="sourceLine" id="cb19-8" title="8"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></a>
<a class="sourceLine" id="cb19-9" title="9"><span class="co">#&gt; [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a>
<a class="sourceLine" id="cb19-10" title="10"><span class="co">#&gt; =&gt; Found 15,851 first weighted isolates (79.3% of total)</span></a></code></pre></div>
<a class="sourceLine" id="cb19-5" title="5"><span class="co">#&gt; [1] "is any"</span></a>
<a class="sourceLine" id="cb19-6" title="6"><span class="co">#&gt; [1] "is any"</span></a>
<a class="sourceLine" id="cb19-7" title="7"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
<a class="sourceLine" id="cb19-8" title="8"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
<a class="sourceLine" id="cb19-9" title="9"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
<a class="sourceLine" id="cb19-10" title="10"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></a>
<a class="sourceLine" id="cb19-11" title="11"><span class="co">#&gt; [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a>
<a class="sourceLine" id="cb19-12" title="12"><span class="co">#&gt; =&gt; Found 15,865 first weighted isolates (79.3% of total)</span></a></code></pre></div>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -654,8 +662,8 @@ @@ -654,8 +662,8 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-02-08</td>
<td align="center">H1</td>
<td align="center">2010-04-19</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -666,44 +674,44 @@ @@ -666,44 +674,44 @@
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-04-06</td>
<td align="center">H1</td>
<td align="center">2010-08-08</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">I</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-04-25</td>
<td align="center">H1</td>
<td align="center">2010-10-31</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-10-05</td>
<td align="center">H1</td>
<td align="center">2010-11-11</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-11-09</td>
<td align="center">H1</td>
<td align="center">2011-04-04</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -714,23 +722,23 @@ @@ -714,23 +722,23 @@
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-11-23</td>
<td align="center">H1</td>
<td align="center">2011-05-22</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-12-26</td>
<td align="center">H1</td>
<td align="center">2011-08-15</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
@ -738,23 +746,23 @@ @@ -738,23 +746,23 @@
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2011-01-01</td>
<td align="center">H1</td>
<td align="center">2011-08-20</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</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">9</td>
<td align="center">2011-01-21</td>
<td align="center">H1</td>
<td align="center">2011-08-25</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</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">FALSE</td>
@ -762,23 +770,23 @@ @@ -762,23 +770,23 @@
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-02-28</td>
<td align="center">H1</td>
<td align="center">2011-12-16</td>
<td align="center">S8</td>
<td align="center">B_ESCHR_COL</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">TRUE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
</tbody>
</table>
<p>Instead of 2, now 10 isolates are flagged. In total, 79.3% of all isolates are marked ‘first weighted’ - 50.9% 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 9 isolates are flagged. In total, 79.3% of all isolates are marked ‘first weighted’ - 51% 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="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" title="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb20-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</a></code></pre></div>
<p>So we end up with 15,851 isolates for analysis.</p>
<p>So we end up with 15,865 isolates for analysis.</p>
<p>We can remove unneeded columns:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" title="1">data_1st &lt;-<span class="st"> </span>data_1st <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb21-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(first, keyab))</a></code></pre></div>
@ -786,6 +794,7 @@ @@ -786,6 +794,7 @@
<div class="sourceCode" id="cb22"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb22-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">head</a></span>(data_1st)</a></code></pre></div>
<table class="table">
<thead><tr class="header">
<th></th>
<th align="center">date</th>
<th align="center">patient_id</th>
<th align="center">hospital</th>
@ -802,93 +811,99 @@ @@ -802,93 +811,99 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2011-09-14</td>
<td align="center">N3</td>
<td align="center">Hospital B</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td>2</td>
<td align="center">2011-10-29</td>
<td align="center">H5</td>
<td align="center">Hospital D</td>
<td align="center">B_STRPT_PNE</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</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">Gram positive</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2011-01-09</td>
<td align="center">I3</td>
<td align="center">Hospital A</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td>3</td>
<td align="center">2013-02-03</td>
<td align="center">D7</td>
<td align="center">Hospital D</td>
<td align="center">B_STRPT_PNE</td>
<td align="center">S</td>
<td align="center">S</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">2015-06-02</td>
<td align="center">E8</td>
<td align="center">Hospital A</td>
<td align="center">B_STRPT_PNE</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</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="center">2011-02-06</td>
<td align="center">S1</td>
<td align="center">Hospital D</td>
<tr class="odd">
<td>4</td>
<td align="center">2013-01-14</td>
<td align="center">U1</td>
<td align="center">Hospital C</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</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 negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>5</td>
<td align="center">2010-02-23</td>
<td align="center">O7</td>
<td align="center">Hospital A</td>
<td align="center">B_STPHY_AUR</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">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">2010-01-27</td>
<td align="center">N7</td>
<td align="center">Hospital C</td>
<td align="center">B_ESCHR_COL</td>
<td>6</td>
<td align="center">2010-09-26</td>
<td align="center">E6</td>
<td align="center">Hospital D</td>
<td align="center">B_KLBSL_PNE</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">R</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">Escherichia</td>
<td align="center">coli</td>
<td align="center">Klebsiella</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2017-08-11</td>
<td align="center">U3</td>
<td>8</td>
<td align="center">2017-06-19</td>
<td align="center">J3</td>
<td align="center">Hospital B</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">B_STPHY_AUR</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>
<td align="center">Gram negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">M</td>
<td align="center">Gram positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">TRUE</td>
</tr>
</tbody>
@ -908,9 +923,9 @@ @@ -908,9 +923,9 @@
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb23-1" title="1"><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/paste">paste</a></span>(data_1st<span class="op">$</span>genus, data_1st<span class="op">$</span>species))</a></code></pre></div>
<p>Or can be used like the <code>dplyr</code> way, which is easier readable:</p>
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb24-1" title="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(genus, species)</a></code></pre></div>
<p><strong>Frequency table of <code>genus</code> and <code>species</code> from a <code>data.frame</code> (15,851 x 13)</strong></p>
<p><strong>Frequency table of <code>genus</code> and <code>species</code> from a <code>data.frame</code> (15,865 x 13)</strong></p>
<p>Columns: 2<br>
Length: 15,851 (of which NA: 0 = 0.00%)<br>
Length: 15,865 (of which NA: 0 = 0.00%)<br>
Unique: 4</p>
<p>Shortest: 16<br>
Longest: 24</p>
@ -927,33 +942,33 @@ Longest: 24</p> @@ -927,33 +942,33 @@ Longest: 24</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Escherichia coli</td>
<td align="right">7,800</td>
<td align="right">49.2%</td>
<td align="right">7,800</td>
<td align="right">49.2%</td>
<td align="right">7,999</td>
<td align="right">50.4%</td>
<td align="right">7,999</td>
<td align="right">50.4%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Staphylococcus aureus</td>
<td align="right">4,008</td>
<td align="right">25.3%</td>
<td align="right">11,808</td>
<td align="right">74.5%</td>
<td align="right">3,900</td>
<td align="right">24.6%</td>
<td align="right">11,899</td>
<td align="right">75.0%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td>
<td align="right">2,445</td>
<td align="right">15.4%</td>
<td align="right">14,253</td>
<td align="right">89.9%</td>
<td align="right">2,453</td>
<td align="right">15.5%</td>
<td align="right">14,352</td>
<td align="right">90.5%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td>
<td align="right">1,598</td>
<td align="right">10.1%</td>
<td align="right">15,851</td>
<td align="right">1,513</td>
<td align="right">9.5%</td>
<td align="right">15,865</td>
<td align="right">100.0%</td>
</tr>
</tbody>
@ -964,7 +979,7 @@ Longest: 24</p> @@ -964,7 +979,7 @@ Longest: 24</p>
<a href="#resistance-percentages" class="anchor"></a>Resistance percentages</h2>
<p>The functions <code>portion_R</code>, <code>portion_RI</code>, <code>portion_I</code>, <code>portion_IS</code> and <code>portion_S</code> can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:</p>
<div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb25-1" title="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_IR</a></span>(amox)</a>
<a class="sourceLine" id="cb25-2" title="2"><span class="co">#&gt; [1] 0.4828087</span></a></code></pre></div>
<a class="sourceLine" id="cb25-2" title="2"><span class="co">#&gt; [1] 0.4755121</span></a></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="cb26"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb26-1" title="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb26-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital) <span class="op">%&gt;%</span><span class="st"> </span></a>
@ -977,19 +992,19 @@ Longest: 24</p> @@ -977,19 +992,19 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4877378</td>
<td align="center">0.4644901</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4750000</td>
<td align="center">0.4754156</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4869240</td>
<td align="center">0.4927721</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4860406</td>
<td align="center">0.4793125</td>
</tr>
</tbody>
</table>
@ -1007,23 +1022,23 @@ Longest: 24</p> @@ -1007,23 +1022,23 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4877378</td>
<td align="center">4730</td>
<td align="center">0.4644901</td>
<td align="center">4717</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4750000</td>
<td align="center">5560</td>
<td align="center">0.4754156</td>
<td align="center">5654</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4869240</td>
<td align="center">2409</td>
<td align="center">0.4927721</td>
<td align="center">2352</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4860406</td>
<td align="center">3152</td>
<td align="center">0.4793125</td>
<td align="center">3142</td>
</tr>
</tbody>
</table>
@ -1043,27 +1058,27 @@ Longest: 24</p> @@ -1043,27 +1058,27 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Escherichia</td>
<td align="center">0.7452564</td>
<td align="center">0.9002564</td>
<td align="center">0.9765385</td>
<td align="center">0.7249656</td>
<td align="center">0.8993624</td>
<td align="center">0.9729966</td>
</tr>
<tr class="even">
<td align="center">Klebsiella</td>
<td align="center">0.7509387</td>
<td align="center">0.9030038</td>
<td align="center">0.9724656</td>
<td align="center">0.7336418</td>
<td align="center">0.9035030</td>
<td align="center">0.9801718</td>
</tr>
<tr class="odd">
<td align="center">Staphylococcus</td>
<td align="center">0.7262974</td>
<td align="center">0.9224052</td>
<td align="center">0.9790419</td>
<td align="center">0.7261538</td>
<td align="center">0.9179487</td>
<td align="center">0.9789744</td>
</tr>
<tr class="even">
<td align="center">Streptococcus</td>
<td align="center">0.7325153</td>
<td align="center">0.7382797</td>
<td align="center">0.0000000</td>
<td align="center">0.7325153</td>
<td align="center">0.7382797</td>
</tr>
</tbody>
</table>

BIN
docs/articles/AMR_files/figure-html/plot 1-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

BIN
docs/articles/AMR_files/figure-html/plot 3-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

BIN
docs/articles/AMR_files/figure-html/plot 4-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

BIN
docs/articles/AMR_files/figure-html/plot 5-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

1
docs/articles/WHONET.html

@ -231,6 +231,7 @@ @@ -231,6 +231,7 @@
<p>No errors or warnings, so all values are transformed succesfully. Let’s check it though, with a couple of frequency tables:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="co"># our newly created `mo` variable</span></a>
<a class="sourceLine" id="cb4-2" title="2">data <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(mo, <span class="dt">nmax =</span> <span class="dv">10</span>)</a></code></pre></div>
<p>[1] “is any” [1] “is any” [1] “is any”</p>
<p><strong>Frequency table of <code>mo</code> from a <code>data.frame</code> (500 x 54)</strong></p>
<p>Class: <code>mo</code> (<code>character</code>)<br>
Length: 500 (of which NA: 0 = 0.00%)<br>

104
docs/articles/benchmarks.html

@ -217,15 +217,15 @@ @@ -217,15 +217,15 @@
<a class="sourceLine" id="cb2-8" title="8"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb2-9" title="9"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb2-10" title="10"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#&gt; as.mo("sau") 10.4 10.5 10.7 10.6 10.7 11.2 10</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#&gt; as.mo("stau") 84.4 84.7 95.6 85.2 101.0 136.0 10</span></a>
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#&gt; as.mo("staaur") 10.5 10.6 10.8 10.6 11.1 11.2 10</span></a>
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#&gt; as.mo("S. aureus") 21.3 21.4 31.4 21.9 41.6 60.3 10</span></a>
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#&gt; as.mo("S. aureus") 21.3 21.4 21.8 21.4 21.5 24.9 10</span></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#&gt; as.mo("STAAUR") 10.5 10.6 23.5 10.6 43.8 65.0 10</span></a>