Browse Source

as.mo improvement

new-mo-algorithm
parent
commit
f9ded23023
  1. 4
      DESCRIPTION
  2. 8
      NEWS.md
  3. 21
      R/catalogue_of_life.R
  4. 14
      R/data.R
  5. 19
      R/mo.R
  6. 82
      R/mo_property.R
  7. BIN
      data/microorganisms.rda
  8. 2
      docs/LICENSE-text.html
  9. 384
      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. 4
      docs/articles/EUCAST.html
  15. 4
      docs/articles/G_test.html
  16. 2
      docs/articles/SPSS.html
  17. 4
      docs/articles/WHONET.html
  18. 4
      docs/articles/atc_property.html
  19. BIN
      docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png
  20. 2
      docs/articles/index.html
  21. 2
      docs/authors.html
  22. 2
      docs/index.html
  23. 2
      docs/reference/AMR-deprecated.html
  24. 2
      docs/reference/AMR.html
  25. 2
      docs/reference/WHOCC.html
  26. 2
      docs/reference/WHONET.html
  27. 2
      docs/reference/abname.html
  28. 2
      docs/reference/age.html
  29. 2
      docs/reference/age_groups.html
  30. 2
      docs/reference/antibiotics.html
  31. 2
      docs/reference/as.atc.html
  32. 2
      docs/reference/as.mic.html
  33. 2
      docs/reference/as.mo.html
  34. 2
      docs/reference/as.rsi.html
  35. 2
      docs/reference/atc_online.html
  36. 2
      docs/reference/atc_property.html
  37. 2
      docs/reference/availability.html
  38. 2
      docs/reference/catalogue_of_life.html
  39. 16
      docs/reference/catalogue_of_life_version.html
  40. 2
      docs/reference/count.html
  41. 2
      docs/reference/eucast_rules.html
  42. 2
      docs/reference/first_isolate.html
  43. 2
      docs/reference/freq.html
  44. 2
      docs/reference/g.test.html
  45. 2
      docs/reference/get_locale.html
  46. 2
      docs/reference/ggplot_rsi.html
  47. 2
      docs/reference/guess_ab_col.html
  48. 2
      docs/reference/index.html
  49. 2
      docs/reference/join.html
  50. 2
      docs/reference/key_antibiotics.html
  51. 2
      docs/reference/kurtosis.html
  52. 2
      docs/reference/like.html
  53. 2
      docs/reference/mdro.html
  54. 2
      docs/reference/microorganisms.codes.html
  55. 2
      docs/reference/microorganisms.html
  56. 2
      docs/reference/microorganisms.old.html
  57. 2
      docs/reference/mo_property.html
  58. 2
      docs/reference/mo_source.html
  59. 2
      docs/reference/p.symbol.html
  60. 2
      docs/reference/portion.html
  61. 2
      docs/reference/read.4D.html
  62. 2
      docs/reference/resistance_predict.html
  63. 2
      docs/reference/rsi.html
  64. 2
      docs/reference/septic_patients.html
  65. 2
      docs/reference/skewness.html
  66. 9
      man/catalogue_of_life_version.Rd
  67. 8
      reproduction_of_microorganisms.R

4
DESCRIPTION

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
Package: AMR
Version: 0.5.0.9018
Date: 2019-02-25
Version: 0.5.0.9019
Date: 2019-02-26
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(

8
NEWS.md

@ -12,13 +12,11 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git @@ -12,13 +12,11 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
* **BREAKING**: removed deprecated functions, parameters and references to 'bactid'. Use `as.mo()` to identify an MO code.
* Catalogue of Life as a new taxonomic source for data about microorganisms, which also contains all ITIS data we used previously. The `microorganisms` data set now contains:
* All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
* All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales.
The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant (sub)species are covered (like all species of *Aspergillus*, *Candida*, *Pneumocystis*, *Saccharomyces* and *Trichophyton*).
* All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales (covering at least like all species of *Aspergillus*, *Candida*, *Pneumocystis*, *Saccharomyces* and *Trichophyton*)
* All ~15,000 previously accepted names of included (sub)species that have been taxonomically renamed
* The responsible author(s) and year of scientific publication
This data is updated annually - check the included version with `catalogue_of_life_version()`.
This data is updated annually - check the included version with the new function `catalogue_of_life_version()`.
* Due to this change, some `mo` codes changed (e.g. *Streptococcus* changed from `B_STRPTC` to `B_STRPT`). A translation table is used internally to support older microorganism IDs, so users will not notice this difference.
* New function `mo_rank()` for the taxonomic rank (genus, species, infraspecies, etc.)
* New function `mo_url()` to get the URL to the Catalogue of Life
@ -86,7 +84,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git @@ -86,7 +84,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
* Better handling for *Salmonellae*
* Understanding of highly virulent *E. coli* strains like EIEC, EPEC and STEC
* There will be looked for uncertain results at default - these results will be returned with an informative warning
* Manual now contains more info about the algorithms
* Manual (help page) now contains more info about the algorithms
* Progress bar will be shown when it takes more than 3 seconds to get results
* Support for formatted console text
* Console will return the percentage of uncoercable input

21
R/catalogue_of_life.R

@ -71,3 +71,24 @@ @@ -71,3 +71,24 @@
#' mo_fullname("C. elegans")
#' # [1] "Chroococcus limneticus elegans" # Because a microorganism was found
NULL
#' Version info of included Catalogue of Life
#'
#' This function returns a list with info about the included data from the Catalogue of Life. It also shows if the included version is their latest annual release. The Catalogue of Life releases their annual release in March each year.
#' @seealso \code{\link{microorganisms}}
#' @inheritSection catalogue_of_life Catalogue of Life
#' @inheritSection AMR Read more on our website!
#' @export
#' @examples
#' library(dplyr)
#' microorganisms %>% freq(kingdom)
#' microorganisms %>% group_by(kingdom) %>% freq(phylum, nmax = NULL)
catalogue_of_life_version <- function() {
# see the `catalogue_of_life` list in R/data.R
list(version = catalogue_of_life$version,
url = catalogue_of_life$url,
# annual release always somewhere in March
is_latest_annual_release = Sys.Date() < as.Date(paste0(catalogue_of_life$year + 1, "-04-01")),
n_species = nrow(AMR::microorganisms),
n_synonyms = nrow(AMR::microorganisms.old))
}

14
R/data.R

@ -168,20 +168,6 @@ catalogue_of_life <- list( @@ -168,20 +168,6 @@ catalogue_of_life <- list(
url = "http://www.catalogueoflife.org/annual-checklist/2018"
)
#' Version info of included Catalogue of Life
#' @seealso \code{\link{microorganisms}}
#' @inheritSection catalogue_of_life Catalogue of Life
#' @inheritSection AMR Read more on our website!
#' @export
catalogue_of_life_version <- function() {
list(version = catalogue_of_life$version,
url = catalogue_of_life$url,
# annual release always somewhere in March
is_latest_annual_release = Sys.Date() < as.Date(paste0(catalogue_of_life$year + 1, "-04-01")),
no_of_species = nrow(AMR::microorganisms),
no_of_synonyms = nrow(AMR::microorganisms.old))
}
#' Data set with previously accepted taxonomic names
#'
#' A data set containing old (previously valid or accepted) taxonomic names according to the Catalogue of Life. This data set is used internally by \code{\link{as.mo}}.

19
R/mo.R

@ -166,7 +166,12 @@ @@ -166,7 +166,12 @@
#' mutate(mo = as.mo(paste(genus, species)))
#' }
as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE, reference_df = get_mo_source()) {
if (all(x %in% AMR::microorganisms$fullname)
if (all(x %in% AMR::microorganisms$mo)
& isFALSE(Becker)
& isFALSE(Lancefield)
& is.null(reference_df)) {
y <- x
} else if (all(x %in% AMR::microorganisms$fullname)
& isFALSE(Becker)
& isFALSE(Lancefield)
& is.null(reference_df)) {
@ -179,12 +184,13 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE, @@ -179,12 +184,13 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE,
if (any(is.na(y))) {
y[is.na(y)] <- microorganismsDT[prevalence == 3][data.table(fullname = x[is.na(y)]), on = "fullname", "mo"][[1]]
}
return(y)
} else {
# will be checked for mo class in validation and uses exec_as.mo internally if necessary
y <- mo_validate(x = x, property = "mo",
Becker = Becker, Lancefield = Lancefield,
allow_uncertain = allow_uncertain, reference_df = reference_df)
}
# will be checked for mo class in validation
mo_validate(x = x, property = "mo",
Becker = Becker, Lancefield = Lancefield,
allow_uncertain = allow_uncertain, reference_df = reference_df)
structure(.Data = y, class = "mo")
}
#' @rdname as.mo
@ -891,6 +897,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, @@ -891,6 +897,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
stringsAsFactors = FALSE)
df_input <- data.frame(input = as.character(x_input),
stringsAsFactors = FALSE)
x <- df_input %>%
left_join(df_found,
by = "input") %>%

82
R/mo_property.R

@ -132,7 +132,7 @@ @@ -132,7 +132,7 @@
#' mo_taxonomy("E. coli")
mo_fullname <- function(x, language = get_locale(), ...) {
x <- mo_validate(x = x, property = "fullname", ...)
mo_translate(x, language = language)
translate(x, language = language)
}
#' @rdname mo_property
@ -148,46 +148,64 @@ mo_shortname <- function(x, language = get_locale(), ...) { @@ -148,46 +148,64 @@ mo_shortname <- function(x, language = get_locale(), ...) {
if (is.null(Lancefield)) {
Lancefield <- FALSE
}
if (Becker %in% c(TRUE, "all") | Lancefield == TRUE) {
shorten <- function(x) {
# easiest: no transformations needed
x <- mo_fullname(x, language = "en")
# shorten for the ones that have a space: shorten first word and write out second word
shorten_these <- x %like% " " & !x %like% "Streptococcus group "
x[shorten_these] <- paste0(substr(x[shorten_these], 1, 1),
". ",
x[shorten_these] %>%
strsplit(" ", fixed = TRUE) %>%
unlist() %>%
.[2])
x
}
if (isFALSE(Becker) & isFALSE(Lancefield)) {
result <- shorten(x)
} else {
# get result without transformations
res1 <- AMR::as.mo(x, Becker = FALSE, Lancefield = FALSE, reference_df = dots$reference_df)
# and result with transformations
res2 <- suppressWarnings(AMR::as.mo(res1, ...))
res2_fullname <- mo_fullname(res2, language = language)
res2_fullname[res2_fullname %like% " \\(CoNS\\)"] <- "CoNS"
res2_fullname[res2_fullname %like% " \\(CoPS\\)"] <- "CoPS"
res2_fullname[res2_fullname %like% " \\(KNS\\)"] <- "KNS"
res2_fullname[res2_fullname %like% " \\(KPS\\)"] <- "KPS"
res2_fullname[res2_fullname %like% " \\(CNS\\)"] <- "CNS"
res2_fullname[res2_fullname %like% " \\(CPS\\)"] <- "CPS"
res2_fullname <- gsub("Streptococcus (group|Gruppe|gruppe|groep|grupo|gruppo|groupe) (.)",
"G\\2S",
res2_fullname) # turn "Streptococcus group A" and "Streptococcus grupo A" to "GAS"
res2_fullname_vector <- res2_fullname[res2_fullname == mo_fullname(res1)]
res2_fullname[res2_fullname == mo_fullname(res1)] <- paste0(substr(mo_genus(res2_fullname_vector), 1, 1),
". ",
suppressWarnings(mo_species(res2_fullname_vector)))
if (sum(res1 == res2, na.rm = TRUE) > 0) {
res1[res1 == res2] <- paste0(substr(mo_genus(res1[res1 == res2]), 1, 1),
". ",
suppressWarnings(mo_species(res1[res1 == res2])))
if (res1 == res2
& !res1 %like% "^B_STRPT_GR") {
result <- shorten(x)
} else {
res2_fullname <- mo_fullname(res2, language = language)
res2_fullname[res2_fullname %like% " \\(CoNS\\)"] <- "CoNS"
res2_fullname[res2_fullname %like% " \\(CoPS\\)"] <- "CoPS"
res2_fullname[res2_fullname %like% " \\(KNS\\)"] <- "KNS"
res2_fullname[res2_fullname %like% " \\(KPS\\)"] <- "KPS"
res2_fullname[res2_fullname %like% " \\(CNS\\)"] <- "CNS"
res2_fullname[res2_fullname %like% " \\(CPS\\)"] <- "CPS"
res2_fullname <- gsub("Streptococcus (group|Gruppe|gruppe|groep|grupo|gruppo|groupe) (.)",
"G\\2S",
res2_fullname) # turn "Streptococcus group A" and "Streptococcus grupo A" to "GAS"
res2_fullname_vector <- res2_fullname[res2_fullname == mo_fullname(res1)]
res2_fullname[res2_fullname == mo_fullname(res1)] <- paste0(substr(mo_genus(res2_fullname_vector), 1, 1),
". ",
suppressWarnings(mo_species(res2_fullname_vector)))
if (sum(res1 == res2, na.rm = TRUE) > 0) {
res1[res1 == res2] <- paste0(substr(mo_genus(res1[res1 == res2]), 1, 1),
". ",
suppressWarnings(mo_species(res1[res1 == res2])))
}
res1[res1 != res2] <- res2_fullname
result <- as.character(res1)
}
res1[res1 != res2] <- res2_fullname
result <- as.character(res1)
} else {
x <- AMR::as.mo(x, ...)
suppressWarnings(
result <- data.frame(mo = x) %>%
left_join(AMR::microorganisms, by = "mo") %>%
mutate(shortname = ifelse(!is.na(genus) & !is.na(species), paste0(substr(genus, 1, 1), ". ", species), NA_character_)) %>%
pull(shortname)
)
}
mo_translate(result, language = language)
translate(result, language = language)
}
#' @rdname mo_property
#' @export
mo_subspecies <- function(x, language = get_locale(), ...) {
mo_translate(mo_validate(x = x, property = "subspecies", ...), language = language)
translate(validate(x = x, property = "subspecies", ...), language = language)
}
#' @rdname mo_property

BIN
data/microorganisms.rda

Binary file not shown.

2
docs/LICENSE-text.html

@ -78,7 +78,7 @@ @@ -78,7 +78,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="Released version">0.5.0.9018</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9019</span>
</span>
</div>

384
docs/articles/AMR.html

@ -40,7 +40,7 @@ @@ -40,7 +40,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="Released version">0.5.0.9018</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9019</span>
</span>
</div>
@ -192,7 +192,7 @@ @@ -192,7 +192,7 @@
<h1>How to conduct AMR analysis</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">25 February 2019</h4>
<h4 class="date">26 February 2019</h4>
<div class="hidden name"><code>AMR.Rmd</code></div>
@ -201,7 +201,7 @@ @@ -201,7 +201,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/">RMarkdown</a>. However, the methodology remains unchanged. This page was generated on 25 February 2019.</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/">RMarkdown</a>. However, the methodology remains unchanged. This page was generated on 26 February 2019.</p>
<div id="introduction" class="section level1">
<h1 class="hasAnchor">
<a href="#introduction" class="anchor"></a>Introduction</h1>
@ -217,21 +217,21 @@ @@ -217,21 +217,21 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2019-02-25</td>
<td align="center">2019-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">2019-02-25</td>
<td align="center">2019-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">2019-02-25</td>
<td align="center">2019-02-26</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@ -327,21 +327,21 @@ @@ -327,21 +327,21 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2011-05-27</td>
<td align="center">C5</td>
<td align="center">Hospital B</td>
<td align="center">2015-04-06</td>
<td align="center">E7</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">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2010-08-22</td>
<td align="center">Q6</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia coli</td>
<td align="center">2016-10-23</td>
<td align="center">S6</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>
@ -349,20 +349,20 @@ @@ -349,20 +349,20 @@
<td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2017-03-11</td>
<td align="center">V9</td>
<td align="center">Hospital A</td>
<td align="center">Klebsiella pneumoniae</td>
<td align="center">S</td>
<td align="center">2010-02-02</td>
<td align="center">O1</td>
<td align="center">Hospital D</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">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2012-12-25</td>
<td align="center">A1</td>
<td align="center">Hospital B</td>
<td align="center">2014-03-12</td>
<td align="center">H4</td>
<td align="center">Hospital A</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
@ -371,22 +371,22 @@ @@ -371,22 +371,22 @@
<td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2011-09-17</td>
<td align="center">I5</td>
<td align="center">2011-11-01</td>
<td align="center">X1</td>
<td align="center">Hospital B</td>
<td align="center">Escherichia coli</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">R</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2017-05-19</td>
<td align="center">O7</td>
<td align="center">Hospital C</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td>
<td align="center">2016-12-10</td>
<td align="center">W4</td>
<td align="center">Hospital B</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
@ -411,8 +411,8 @@ @@ -411,8 +411,8 @@
#&gt;
#&gt; Item Count Percent Cum. Count Cum. Percent
#&gt; --- ----- ------- -------- ----------- -------------
#&gt; 1 M 10,437 52.2% 10,437 52.2%
#&gt; 2 F 9,563 47.8% 20,000 100.0%</code></pre>
#&gt; 1 M 10,479 52.4% 10,479 52.4%
#&gt; 2 F 9,521 47.6% 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>
@ -443,10 +443,10 @@ @@ -443,10 +443,10 @@
<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 (1294 changes)</span></a>
<a class="sourceLine" id="cb14-22" title="22"><span class="co">#&gt; Table 1: Intrinsic resistance in Enterobacteriaceae (1324 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 (2675 changes)</span></a>
<a class="sourceLine" id="cb14-25" title="25"><span class="co">#&gt; Table 4: Intrinsic resistance in Gram-positive bacteria (2776 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>
@ -462,9 +462,9 @@ @@ -462,9 +462,9 @@
<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,390 out of 20,000 rows</span></a>
<a class="sourceLine" id="cb14-41" title="41"><span class="co">#&gt; =&gt; EUCAST rules affected 7,376 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 3,969 test results (0 to S; 0 to I; 3,969 to R)</span></a></code></pre></div>
<a class="sourceLine" id="cb14-43" title="43"><span class="co">#&gt; -&gt; changed 4,100 test results (0 to S; 0 to I; 4,100 to R)</span></a></code></pre></div>
</div>
<div id="adding-new-variables" class="section level1">
<h1 class="hasAnchor">
@ -489,7 +489,7 @@ @@ -489,7 +489,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,670 first isolates (28.4% of total)</span></a></code></pre></div>
<a class="sourceLine" id="cb16-6" title="6"><span class="co">#&gt; =&gt; Found 5,678 first isolates (28.4% of total)</span></a></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>
<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,43 +516,43 @@ @@ -516,43 +516,43 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-03-10</td>
<td align="center">F7</td>
<td align="center">2010-01-25</td>
<td align="center">B9</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">R</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-12</td>
<td align="center">F7</td>
<td align="center">2010-03-01</td>
<td align="center">B9</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">I</td>
<td align="center">I</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">3</td>
<td align="center">2010-06-18</td>
<td align="center">F7</td>
<td align="center">2010-06-15</td>
<td align="center">B9</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="even">
<td align="center">4</td>
<td align="center">2010-10-16</td>
<td align="center">F7</td>
<td align="center">2010-07-08</td>
<td align="center">B9</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">S</td>
<td align="center">S</td>
@ -560,8 +560,8 @@ @@ -560,8 +560,8 @@
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-11-12</td>
<td align="center">F7</td>
<td align="center">2010-07-20</td>
<td align="center">B9</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -571,19 +571,19 @@ @@ -571,19 +571,19 @@
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-11-24</td>
<td align="center">F7</td>
<td align="center">2010-09-18</td>
<td align="center">B9</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">7</td>
<td align="center">2011-02-24</td>
<td align="center">F7</td>
<td align="center">2010-09-21</td>
<td align="center">B9</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -593,21 +593,21 @@ @@ -593,21 +593,21 @@
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2011-03-30</td>
<td align="center">F7</td>
<td align="center">2010-11-24</td>
<td align="center">B9</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">S</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2011-08-09</td>
<td align="center">F7</td>
<td align="center">2010-12-08</td>
<td align="center">B9</td>
<td align="center">B_ESCHR_COL</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>
@ -615,18 +615,18 @@ @@ -615,18 +615,18 @@
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-08-14</td>
<td align="center">F7</td>
<td align="center">2011-01-19</td>
<td align="center">B9</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</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>
</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="cb19"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb19-1" title="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<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>
@ -637,7 +637,7 @@ @@ -637,7 +637,7 @@
<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,887 first weighted isolates (79.4% of total)</span></a></code></pre></div>
<a class="sourceLine" id="cb19-10" title="10"><span class="co">#&gt; =&gt; Found 15,822 first weighted isolates (79.1% of total)</span></a></code></pre></div>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -654,46 +654,46 @@ @@ -654,46 +654,46 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-03-10</td>
<td align="center">F7</td>
<td align="center">2010-01-25</td>
<td align="center">B9</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">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-03-12</td>
<td align="center">F7</td>
<td align="center">2010-03-01</td>
<td align="center">B9</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">I</td>
<td align="center">I</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">3</td>
<td align="center">2010-06-18</td>
<td align="center">F7</td>
<td align="center">2010-06-15</td>
<td align="center">B9</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">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-10-16</td>
<td align="center">F7</td>
<td align="center">2010-07-08</td>
<td align="center">B9</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">S</td>
<td align="center">S</td>
@ -702,58 +702,58 @@ @@ -702,58 +702,58 @@
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-11-12</td>
<td align="center">F7</td>
<td align="center">2010-07-20</td>
<td align="center">B9</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">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-11-24</td>
<td align="center">F7</td>
<td align="center">2010-09-18</td>
<td align="center">B9</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">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2011-02-24</td>
<td align="center">F7</td>
<td align="center">2010-09-21</td>
<td align="center">B9</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">FALSE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2011-03-30</td>
<td align="center">F7</td>
<td align="center">2010-11-24</td>
<td align="center">B9</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">S</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2011-08-09</td>
<td align="center">F7</td>
<td align="center">2010-12-08</td>
<td align="center">B9</td>
<td align="center">B_ESCHR_COL</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>
@ -762,11 +762,11 @@ @@ -762,11 +762,11 @@
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-08-14</td>
<td align="center">F7</td>
<td align="center">2011-01-19</td>
<td align="center">B9</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</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>
@ -774,11 +774,11 @@ @@ -774,11 +774,11 @@
</tr>
</tbody>
</table>
<p>Instead of 2, now 5 isolates are flagged. In total, 79.4% of all isolates are marked ‘first weighted’ - 51.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>Instead of 1, now 9 isolates are flagged. In total, 79.1% of all isolates are marked ‘first weighted’ - 50.7% 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,887 isolates for analysis.</p>
<p>So we end up with 15,822 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>
@ -804,14 +804,14 @@ @@ -804,14 +804,14 @@
<tbody>
<tr class="odd">
<td>1</td>
<td align="center">2011-05-27</td>
<td align="center">C5</td>
<td align="center">Hospital B</td>
<td align="center">2015-04-06</td>
<td align="center">E7</td>
<td align="center">Hospital C</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">R</td>
<td align="center">M</td>
<td align="center">Gram negative</td>
<td align="center">Escherichia</td>
@ -820,46 +820,46 @@ @@ -820,46 +820,46 @@
</tr>
<tr class="even">
<td>2</td>
<td align="center">2010-08-22</td>
<td align="center">Q6</td>
<td align="center">Hospital D</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">2016-10-23</td>
<td align="center">S6</td>
<td align="center">Hospital B</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">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">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>6</td>
<td align="center">2017-05-19</td>
<td align="center">O7</td>
<td align="center">Hospital C</td>
<td align="center">B_STRPT_PNE</td>
<td align="center">S</td>
<td>3</td>
<td align="center">2010-02-02</td>
<td align="center">O1</td>
<td align="center">Hospital D</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">F</td>
<td align="center">Gram positive</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</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>8</td>
<td align="center">2011-01-19</td>
<td align="center">Q7</td>
<td>5</td>
<td align="center">2011-11-01</td>
<td align="center">X1</td>
<td align="center">Hospital B</td>
<td align="center">B_ESCHR_COL</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">R</td>
<td align="center">F</td>
<td align="center">Gram negative</td>
<td align="center">Escherichia</td>
@ -867,35 +867,35 @@ @@ -867,35 +867,35 @@
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>9</td>
<td align="center">2014-06-24</td>
<td align="center">S9</td>
<td>6</td>
<td align="center">2016-12-10</td>
<td align="center">W4</td>
<td align="center">Hospital B</td>
<td align="center">B_STRPT_PNE</td>
<td align="center">R</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">S</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">Gram negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>10</td>
<td align="center">2011-10-01</td>
<td align="center">O10</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AUR</td>
<td align="center">R</td>
<td>7</td>
<td align="center">2015-07-07</td>
<td align="center">P8</td>
<td align="center">Hospital D</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">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">Gram negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
</tbody>
@ -915,9 +915,9 @@ @@ -915,9 +915,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,887 x 13)</strong></p>
<p><strong>Frequency table of <code>genus</code> and <code>species</code> from a <code>data.frame</code> (15,822 x 13)</strong></p>
<p>Columns: 2<br>
Length: 15,887 (of which NA: 0 = 0.00%)<br>
Length: 15,822 (of which NA: 0 = 0.00%)<br>
Unique: 4</p>
<p>Shortest: 16<br>
Longest: 24</p>
@ -934,33 +934,33 @@ Longest: 24</p> @@ -934,33 +934,33 @@ Longest: 24</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Escherichia coli</td>
<td align="right">7,900</td>
<td align="right">49.7%</td>
<td align="right">7,900</td>
<td align="right">49.7%</td>
<td align="right">7,838</td>
<td align="right">49.5%</td>
<td align="right">7,838</td>
<td align="right">49.5%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Staphylococcus aureus</td>
<td align="right">3,951</td>
<td align="right">24.9%</td>
<td align="right">11,851</td>
<td align="right">3,965</td>
<td align="right">25.1%</td>
<td align="right">11,803</td>
<td align="right">74.6%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td>
<td align="right">2,413</td>
<td align="right">15.2%</td>
<td align="right">14,264</td>
<td align="right">89.8%</td>
<td align="right">2,457</td>
<td align="right">15.5%</td>
<td align="right">14,260</td>
<td align="right">90.1%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td>
<td align="right">1,623</td>
<td align="right">10.2%</td>
<td align="right">15,887</td>
<td align="right">1,562</td>
<td align="right">9.9%</td>
<td align="right">15,822</td>
<td align="right">100.0%</td>
</tr>
</tbody>
@ -971,7 +971,7 @@ Longest: 24</p> @@ -971,7 +971,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.4763014</span></a></code></pre></div>
<a class="sourceLine" id="cb25-2" title="2"><span class="co">#&gt; [1] 0.4722538</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>
@ -984,19 +984,19 @@ Longest: 24</p> @@ -984,19 +984,19 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4774125</td>
<td align="center">0.4692014</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4762754</td>
<td align="center">0.4694061</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4630957</td>
<td align="center">0.4845361</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4845070</td>
<td align="center">0.4727669</td>
</tr>
</tbody>
</table>
@ -1014,23 +1014,23 @@ Longest: 24</p> @@ -1014,23 +1014,23 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4774125</td>
<td align="center">4715</td>
<td align="center">0.4692014</td>
<td align="center">4708</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4762754</td>
<td align="center">5606</td>
<td align="center">0.4694061</td>
<td align="center">5573</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4630957</td>
<td align="center">2371</td>
<td align="center">0.4845361</td>
<td align="center">2328</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4845070</td>
<td align="center">3195</td>
<td align="center">0.4727669</td>
<td align="center">3213</td>
</tr>
</tbody>
</table>
@ -1050,27 +1050,27 @@ Longest: 24</p> @@ -1050,27 +1050,27 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Escherichia</td>
<td align="center">0.7267089</td>
<td align="center">0.9002532</td>
<td align="center">0.9720253</td>
<td align="center">0.7269712</td>
<td align="center">0.9050778</td>
<td align="center">0.9744833</td>
</tr>
<tr class="even">
<td align="center">Klebsiella</td>
<td align="center">0.7233518</td>
<td align="center">0.8983364</td>
<td align="center">0.9741220</td>