Browse Source

(v1.1.0.9019) mo_source fix

pull/67/head
parent
commit
ae1969b941
  1. 4
      DESCRIPTION
  2. 7
      NEWS.md
  3. 4
      R/ab_property.R
  4. 1
      R/mo_property.R
  5. 98
      R/mo_source.R
  6. 2
      docs/404.html
  7. 2
      docs/LICENSE-text.html
  8. 431
      docs/articles/AMR.html
  9. BIN
      docs/articles/AMR_files/figure-html/plot 1-1.png
  10. BIN
      docs/articles/AMR_files/figure-html/plot 3-1.png
  11. BIN
      docs/articles/AMR_files/figure-html/plot 4-1.png
  12. BIN
      docs/articles/AMR_files/figure-html/plot 5-1.png
  13. 74
      docs/articles/MDR.html
  14. 93
      docs/articles/PCA.html
  15. BIN
      docs/articles/PCA_files/figure-html/unnamed-chunk-5-1.png
  16. 109
      docs/articles/benchmarks.html
  17. BIN
      docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png
  18. BIN
      docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png
  19. 2
      docs/articles/index.html
  20. 77
      docs/articles/resistance_predict.html
  21. BIN
      docs/articles/resistance_predict_files/figure-html/unnamed-chunk-4-1.png
  22. BIN
      docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-1.png
  23. BIN
      docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-2.png
  24. 2
      docs/authors.html
  25. 5
      docs/extra.css
  26. 6
      docs/index.html
  27. 15
      docs/news/index.html
  28. 2
      docs/pkgdown.yml
  29. 2
      docs/reference/AMR-deprecated.html
  30. 11
      docs/reference/ab_property.html
  31. 2
      docs/reference/age.html
  32. 2
      docs/reference/age_groups.html
  33. 2
      docs/reference/as.ab.html
  34. 2
      docs/reference/as.disk.html
  35. 2
      docs/reference/as.mic.html
  36. 2
      docs/reference/as.mo.html
  37. 2
      docs/reference/as.rsi.html
  38. 2
      docs/reference/atc_online.html
  39. 2
      docs/reference/availability.html
  40. 2
      docs/reference/bug_drug_combinations.html
  41. 2
      docs/reference/count.html
  42. 2
      docs/reference/eucast_rules.html
  43. 2
      docs/reference/filter_ab_class.html
  44. 2
      docs/reference/first_isolate.html
  45. 2
      docs/reference/g.test.html
  46. 2
      docs/reference/ggplot_pca.html
  47. 2
      docs/reference/ggplot_rsi.html
  48. 2
      docs/reference/guess_ab_col.html
  49. 4
      docs/reference/index.html
  50. 2
      docs/reference/join.html
  51. 2
      docs/reference/key_antibiotics.html
  52. 2
      docs/reference/kurtosis.html
  53. 2
      docs/reference/lifecycle.html
  54. 2
      docs/reference/like.html
  55. 2
      docs/reference/mdro.html
  56. 9
      docs/reference/mo_property.html
  57. 55
      docs/reference/mo_source.html
  58. 2
      docs/reference/p_symbol.html
  59. 2
      docs/reference/pca.html
  60. 2
      docs/reference/proportion.html
  61. 2
      docs/reference/resistance_predict.html
  62. 2
      docs/reference/skewness.html
  63. 2
      docs/reference/translate.html
  64. 4
      index.md
  65. 10
      man/ab_property.Rd
  66. 8
      man/mo_property.Rd
  67. 38
      man/mo_source.Rd
  68. 5
      pkgdown/extra.css
  69. 5
      vignettes/AMR.Rmd
  70. 1
      vignettes/MDR.Rmd
  71. 1
      vignettes/PCA.Rmd
  72. 3
      vignettes/benchmarks.Rmd
  73. 4
      vignettes/resistance_predict.Rmd

4
DESCRIPTION

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
Package: AMR
Version: 1.1.0.9018
Date: 2020-05-22
Version: 1.1.0.9019
Date: 2020-05-25
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),

7
NEWS.md

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
# AMR 1.1.0.9018
## <small>Last updated: 22-May-2020</small>
# AMR 1.1.0.9019
## <small>Last updated: 25-May-2020</small>
### Breaking
* Removed code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users.
@ -20,7 +20,8 @@ @@ -20,7 +20,8 @@
* Improvements for algorithm in `as.ab()`, so that e.g. `as.ab("ampi sul")` and `ab_name("ampi sul")` work
* Functions `ab_atc()` and `ab_group()` now return `NA` if no antimicrobial agent could be found
* Small fix for some text input that could not be coerced as valid MIC values
* Fixed interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood)
* Fix for interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood)
* Fix for `set_mo_source()` to make sure that column `mo` will always be the second column
### Other
* Removed previously deprecated function `p.symbol()` - it was replaced with `p_symbol()`

4
R/ab_property.R

@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
#' Property of an antibiotic
#'
#' Use these functions to return a specific property of an antibiotic from the [antibiotics] data set. All input values will be evaluated internally with [as.ab()].
#' @inheritSection lifecycle Maturing lifecycle
#' @inheritSection lifecycle Stable lifecycle
#' @param x any (vector of) text that can be coerced to a valid microorganism code with [as.ab()]
#' @param tolower logical to indicate whether the first character of every output should be transformed to a lower case character. This will lead to e.g. "polymyxin B" and not "polymyxin b".
#' @param property one of the column names of one of the [antibiotics] data set
@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
#' @param ... other parameters passed on to [as.ab()]
#' @details All output will be [translate]d where possible.
#'
#' The function [ab_url()] will return the direct URL to the official WHO website. A warning will be returned if the reauired ATC code is not available.
#' The function [ab_url()] will return the direct URL to the official WHO website. A warning will be returned if the required ATC code is not available.
#' @inheritSection as.ab Source
#' @rdname ab_property
#' @name ab_property

1
R/mo_property.R

@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
#' Property of a microorganism
#'
#' Use these functions to return a specific property of a microorganism. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. Please see *Examples*.
#' @inheritSection lifecycle Stable lifecycle
#' @param x any (vector of) text that can be coerced to a valid microorganism code with [as.mo()]
#' @param property one of the column names of the [microorganisms] data set or `"shortname"`
#' @param language language of the returned text, defaults to system language (see [get_locale()]) and can also be set with `getOption("AMR_locale")`. Use `language = NULL` or `language = ""` to prevent translation.

98
R/mo_source.R

@ -19,13 +19,13 @@ @@ -19,13 +19,13 @@
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
# ==================================================================== #
#' Use predefined reference data set
#' User-defined reference data set for microorganisms
#'
#' @description These functions can be used to predefine your own reference to be used in [as.mo()] and consequently all `mo_*` functions like [mo_genus()] and [mo_gramstain()].
#'
#' This is **the fastest way** to have your organisation (or analysis) specific codes picked up and translated by this package.
#' @inheritSection lifecycle Stable lifecycle
#' @param path location of your reference file, see Details
#' @param path location of your reference file, see Details. Can be `""`, `NULL` or `FALSE` to delete the reference file.
#' @rdname mo_source
#' @name mo_source
#' @aliases set_mo_source get_mo_source
@ -35,11 +35,12 @@ @@ -35,11 +35,12 @@
#'
#' [get_mo_source()] will return the data set by reading `"~/.mo_source.rds"` with [readRDS()]. If the original file has changed (the file defined with `path`), it will call [set_mo_source()] to update the data file automatically.
#'
#' Reading an Excel file (`.xlsx`) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by [get_mo_source()] in only a couple of microseconds (a millionth of a second).
#' Reading an Excel file (`.xlsx`) with only one row has a size of 8-9 kB. The compressed file created with [set_mo_source()] will then have a size of 0.1 kB and can be read by [get_mo_source()] in only a couple of microseconds (millionths of a second).
#'
#' ## How it works
#' @section How to setup:
#'
#' Imagine this data on a sheet of an Excel file (mo codes were looked up in the [microorganisms] data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:
#'
#' Imagine this data on a sheet of an Excel file (mo codes were looked up in the `microorganisms` data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:
#' ```
#' | A | B |
#' --|--------------------|--------------|
@ -50,27 +51,31 @@ @@ -50,27 +51,31 @@
#' ```
#'
#' We save it as `"home/me/ourcodes.xlsx"`. Now we have to set it as a source:
#'
#' ```
#' set_mo_source("home/me/ourcodes.xlsx")
#' # Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#' #> NOTE: Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'
#' #> (columns "Organisation XYZ" and "mo")
#' ```
#'
#' It has now created a file `"~/.mo_source.rds"` with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept.
#' It has now created a file `"~/.mo_source.rds"` with the contents of our Excel file. Only the first column with foreign values and the 'mo' column will be kept when creating the RDS file.
#'
#' And now we can use it in our functions:
#'
#' ```
#' as.mo("lab_mo_ecoli")
#' [1] B_ESCHR_COLI
#' #> [1] B_ESCHR_COLI
#'
#' mo_genus("lab_mo_kpneumoniae")
#' [1] "Klebsiella"
#' #> [1] "Klebsiella"
#'
#' # other input values still work too
#' as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
#' [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
#' #> [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
#' ```
#'
#' If we edit the Excel file to, let's say, by adding row 4 like this:
#' If we edit the Excel file by, let's say, adding row 4 like this:
#'
#' ```
#' | A | B |
#' --|--------------------|--------------|
@ -82,36 +87,41 @@ @@ -82,36 +87,41 @@
#' ```
#'
#' ...any new usage of an MO function in this package will update your data file:
#'
#' ```
#' as.mo("lab_mo_ecoli")
#' # Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#' [1] B_ESCHR_COLI
#' #> NOTE: Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'
#' #> (columns "Organisation XYZ" and "mo")
#' #> [1] B_ESCHR_COLI
#'
#' mo_genus("lab_Staph_aureus")
#' [1] "Staphylococcus"
#' #> [1] "Staphylococcus"
#' ```
#'
#' To remove the reference data file completely, just use `""` or `NULL` as input for `[set_mo_source()]`:
#' To delete the reference data file, just use `""`, `NULL` or `FALSE` as input for [set_mo_source()]:
#'
#' ```
#' set_mo_source(NULL)
#' # Removed mo_source file '~/.mo_source.rds'.
#' ```
#'
#' If the original Excel file is moved or deleted, the mo_source file will be removed upon the next use of [as.mo()]. If the mo_source file is manually deleted (i.e. without using [set_mo_source()]), the references to the mo_source file will be removed upon the next use of [as.mo()].
#' @export
#' @inheritSection AMR Read more on our website!
set_mo_source <- function(path) {
file_location <- path.expand("~/mo_source.rds")
if (!is.character(path) | length(path) > 1) {
stop("`path` must be a character of length 1.")
if (length(path) > 1) {
stop("`path` must be of length 1.")
}
if (path %in% c(NULL, "")) {
if (is.null(path) || path %in% c(FALSE, "")) {
options(mo_source = NULL)
options(mo_source_timestamp = NULL)
if (file.exists(file_location)) {
unlink(file_location)
message("Removed mo_source file '", file_location, "'.")
message(font_red(paste0("Removed mo_source file '", font_bold(file_location), "'")))
}
return(invisible())
}
@ -154,13 +164,13 @@ set_mo_source <- function(path) { @@ -154,13 +164,13 @@ set_mo_source <- function(path) {
# check integrity
mo_source_isvalid(df)
df <- df %>% filter(!is.na(mo))
df <- subset(df, !is.na(mo))
# keep only first two columns, second must be mo
if (colnames(df)[1] == "mo") {
df <- df[, c(2, 1)]
df <- df[, c(colnames(df)[2], "mo")]
} else {
df <- df[, c(1, 2)]
df <- df[, c(colnames(df)[1], "mo")]
}
df <- as.data.frame(df, stringAsFactors = FALSE)
@ -174,30 +184,40 @@ set_mo_source <- function(path) { @@ -174,30 +184,40 @@ set_mo_source <- function(path) {
saveRDS(df, file_location)
options(mo_source = path)
options(mo_source_timestamp = as.character(file.info(path)$mtime))
message(action, " mo_source file '", file_location, "' from '", path, "'.")
message(font_blue(paste0("NOTE: ",
action, " mo_source file '", font_bold(file_location), "'",
" from '", font_bold(path), "'",
'\n (columns "', colnames(df)[1], '" and "', colnames(df)[2], '")')))
}
#' @rdname mo_source
#' @export
get_mo_source <- function() {
if (is.null(getOption("mo_source", NULL))) {
NULL
} else {
old_time <- as.POSIXct(getOption("mo_source_timestamp"))
new_time <- as.POSIXct(as.character(file.info(getOption("mo_source", ""))$mtime))
if (is.na(new_time)) {
# source file was deleted, remove reference too
set_mo_source("")
return(NULL)
}
if (new_time != old_time) {
# set updated source
set_mo_source(getOption("mo_source"))
}
file_location <- path.expand("~/mo_source.rds")
readRDS(file_location)
return(NULL)
}
if (!file.exists(path.expand("~/mo_source.rds"))) {
options(mo_source = NULL)
options(mo_source_timestamp = NULL)
message(font_blue("NOTE: Removed references to deleted mo_source file (see ?mo_source)"))
return(NULL)
}
old_time <- as.POSIXct(getOption("mo_source_timestamp"))
new_time <- as.POSIXct(as.character(file.info(getOption("mo_source", ""))$mtime))
if (is.na(new_time)) {
# source file was deleted, remove reference too
set_mo_source("")
return(NULL)
}
if (new_time != old_time) {
# set updated source
set_mo_source(getOption("mo_source"))
}
file_location <- path.expand("~/mo_source.rds")
readRDS(file_location)
}
mo_source_isvalid <- function(x, refer_to_name = "`reference_df`", stop_on_error = TRUE) {

2
docs/404.html

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

2
docs/LICENSE-text.html

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

431
docs/articles/AMR.html

@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9019</span>
</span>
</div>
@ -186,7 +186,7 @@ @@ -186,7 +186,7 @@
<h1 data-toc-skip>How to conduct AMR analysis</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">20 May 2020</h4>
<h4 class="date">25 May 2020</h4>
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/AMR.Rmd"><code>vignettes/AMR.Rmd</code></a></small>
<div class="hidden name"><code>AMR.Rmd</code></div>
@ -195,7 +195,7 @@ @@ -195,7 +195,7 @@
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 20 May 2020.</p>
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 25 May 2020.</p>
<div id="introduction" class="section level1">
<h1 class="hasAnchor">
<a href="#introduction" class="anchor"></a>Introduction</h1>
@ -226,21 +226,21 @@ @@ -226,21 +226,21 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2020-05-20</td>
<td align="center">2020-05-25</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">2020-05-20</td>
<td align="center">2020-05-25</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">2020-05-20</td>
<td align="center">2020-05-25</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@ -336,70 +336,70 @@ @@ -336,70 +336,70 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2013-03-27</td>
<td align="center">L8</td>
<td align="center">Hospital B</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">R</td>
<td align="center">2015-03-17</td>
<td align="center">U1</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">S</td>
<td align="center">M</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2015-12-30</td>
<td align="center">K1</td>
<td align="center">2017-08-02</td>
<td align="center">P6</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2016-06-06</td>
<td align="center">D3</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">2017-06-24</td>
<td align="center">E4</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">R</td>
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2011-07-04</td>
<td align="center">H10</td>
<td align="center">2011-02-12</td>
<td align="center">I10</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">Streptococcus pneumoniae</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2012-04-12</td>
<td align="center">M3</td>
<td align="center">Hospital B</td>
<td align="center">2010-03-17</td>
<td align="center">Q3</td>
<td align="center">Hospital C</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">M</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2017-03-06</td>
<td align="center">S4</td>
<td align="center">Hospital C</td>
<td align="center">2010-08-19</td>
<td align="center">A7</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">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">M</td>
</tr>
</tbody>
</table>
@ -432,16 +432,16 @@ Longest: 1</p> @@ -432,16 +432,16 @@ Longest: 1</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">M</td>
<td align="right">10,319</td>
<td align="right">51.60%</td>
<td align="right">10,319</td>
<td align="right">51.60%</td>
<td align="right">10,403</td>
<td align="right">52.02%</td>
<td align="right">10,403</td>
<td align="right">52.02%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">F</td>
<td align="right">9,681</td>
<td align="right">48.41%</td>
<td align="right">9,597</td>
<td align="right">47.99%</td>
<td align="right">20,000</td>
<td align="right">100.00%</td>
</tr>
@ -456,11 +456,7 @@ Longest: 1</p> @@ -456,11 +456,7 @@ Longest: 1</p>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span>(<span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span>(<span class="no">AMX</span>:<span class="no">GEN</span>), <span class="no">as.rsi</span>)</pre></body></html></div>
<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>AMX</code>) and amoxicillin/clavulanic acid (column <code>AMC</code>) in our data were generated randomly, some rows will undoubtedly contain AMX = S and AMC = R, which is technically impossible. The <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> fixes this:</p>
<div class="sourceCode" id="cb13"><html><body><pre class="r"><span class="no">data</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(<span class="no">data</span>, <span class="kw">col_mo</span> <span class="kw">=</span> <span class="st">"bacteria"</span>)
<span class="co"># [31m</span>
<span class="co"># Skipping inheritance rules defined by this package, such as setting trimethoprim (TMP) = R where trimethoprim/sulfamethoxazole (SXT) = R.</span>
<span class="co"># Use eucast_rules(..., rules = "all") to also apply those rules.</span>
<span class="co"># [39m</span></pre></body></html></div>
<div class="sourceCode" id="cb13"><html><body><pre class="r"><span class="no">data</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(<span class="no">data</span>, <span class="kw">col_mo</span> <span class="kw">=</span> <span class="st">"bacteria"</span>)</pre></body></html></div>
</div>
<div id="adding-new-variables" class="section level1">
<h1 class="hasAnchor">
@ -482,10 +478,10 @@ Longest: 1</p> @@ -482,10 +478,10 @@ Longest: 1</p>
<p>This <code>AMR</code> package includes this methodology with the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function. It adopts the episode of a year (can be changed by user) and it starts counting days after every selected isolate. This new variable can easily be added to our data:</p>
<div class="sourceCode" id="cb15"><html><body><pre class="r"><span class="no">data</span> <span class="kw">&lt;-</span> <span class="no">data</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="kw">first</span> <span class="kw">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span>(<span class="no">.</span>))
<span class="co"># [34mNOTE: Using column `[1mbacteria[22m` as input for `col_mo`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mdate[22m` as input for `col_date`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mpatient_id[22m` as input for `col_patient_id`.[39m</span></pre></body></html></div>
<p>So only 28.5% 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>
<span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<span class="co"># NOTE: Using column `date` as input for `col_date`.</span>
<span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span></pre></body></html></div>
<p>So only 28.2% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb16"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">&lt;-</span> <span class="no">data</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="no">first</span> <span class="kw">==</span> <span class="fl">TRUE</span>)</pre></body></html></div>
<p>For future use, the above two syntaxes can be shortened with the <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> function:</p>
@ -495,7 +491,7 @@ Longest: 1</p> @@ -495,7 +491,7 @@ Longest: 1</p>
<div id="first-weighted-isolates" class="section level2">
<h2 class="hasAnchor">
<a href="#first-weighted-isolates" class="anchor"></a>First <em>weighted</em> isolates</h2>
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient S1, sorted on date:</p>
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient K4, sorted on date:</p>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -511,32 +507,32 @@ Longest: 1</p> @@ -511,32 +507,32 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-02-10</td>
<td align="center">S1</td>
<td align="center">2010-01-01</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-02-27</td>
<td align="center">S1</td>
<td align="center">2010-02-09</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">I</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-03-05</td>
<td align="center">S1</td>
<td align="center">2010-03-03</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
@ -544,8 +540,8 @@ Longest: 1</p> @@ -544,8 +540,8 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-04-03</td>
<td align="center">S1</td>
<td align="center">2010-04-25</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -555,19 +551,19 @@ Longest: 1</p> @@ -555,19 +551,19 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-05-22</td>
<td align="center">S1</td>
<td align="center">2010-07-04</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-07-19</td>
<td align="center">S1</td>
<td align="center">2010-09-04</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
@ -577,10 +573,10 @@ Longest: 1</p> @@ -577,10 +573,10 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-07-19</td>
<td align="center">S1</td>
<td align="center">2010-10-01</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
@ -588,30 +584,30 @@ Longest: 1</p> @@ -588,30 +584,30 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-08-28</td>
<td align="center">S1</td>
<td align="center">2011-03-20</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">S</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2010-09-09</td>
<td align="center">S1</td>
<td align="center">2011-06-26</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2010-09-20</td>
<td align="center">S1</td>
<td align="center">2011-10-22</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -621,16 +617,16 @@ Longest: 1</p> @@ -621,16 +617,16 @@ Longest: 1</p>
</tr>
</tbody>
</table>
<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>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>If a column exists with a name like ‘key(…)ab’ the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:</p>
<div class="sourceCode" id="cb18"><html><body><pre class="r"><span class="no">data</span> <span class="kw">&lt;-</span> <span class="no">data</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="kw">keyab</span> <span class="kw">=</span> <span class="fu"><a href="../reference/key_antibiotics.html">key_antibiotics</a></span>(<span class="no">.</span>)) <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="kw">first_weighted</span> <span class="kw">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span>(<span class="no">.</span>))
<span class="co"># [34mNOTE: Using column `[1mbacteria[22m` as input for `col_mo`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mbacteria[22m` as input for `col_mo`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mdate[22m` as input for `col_date`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mpatient_id[22m` as input for `col_patient_id`.[39m</span>
<span class="co"># [34mNOTE: Using column `[1mkeyab[22m` as input for `col_keyantibiotics`. Use [1mcol_keyantibiotics = FALSE[22m to prevent this.[39m</span></pre></body></html></div>
<span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<span class="co"># NOTE: Using column `date` as input for `col_date`.</span>
<span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span>
<span class="co"># NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></pre></body></html></div>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -647,44 +643,44 @@ Longest: 1</p> @@ -647,44 +643,44 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-02-10</td>
<td align="center">S1</td>
<td align="center">2010-01-01</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-02-27</td>
<td align="center">S1</td>
<td align="center">2010-02-09</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">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="odd">
<td align="center">3</td>
<td align="center">2010-03-05</td>
<td align="center">S1</td>
<td align="center">2010-03-03</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</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>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-04-03</td>
<td align="center">S1</td>
<td align="center">2010-04-25</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -695,34 +691,34 @@ Longest: 1</p> @@ -695,34 +691,34 @@ Longest: 1</p>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-05-22</td>
<td align="center">S1</td>
<td align="center">2010-07-04</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-07-19</td>
<td align="center">S1</td>
<td align="center">2010-09-04</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</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">7</td>
<td align="center">2010-07-19</td>
<td align="center">S1</td>
<td align="center">2010-10-01</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
@ -731,32 +727,32 @@ Longest: 1</p> @@ -731,32 +727,32 @@ Longest: 1</p>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-08-28</td>
<td align="center">S1</td>
<td align="center">2011-03-20</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">S</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2010-09-09</td>
<td align="center">S1</td>
<td align="center">2011-06-26</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2010-09-20</td>
<td align="center">S1</td>
<td align="center">2011-10-22</td>
<td align="center">K4</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td align="center">S</td>
@ -767,11 +763,11 @@ Longest: 1</p> @@ -767,11 +763,11 @@ Longest: 1</p>
</tr>
</tbody>
</table>
<p>Instead of 1, now 10 isolates are flagged. In total, 78.4% of all isolates are marked ‘first weighted’ - 49.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 7 isolates are flagged. In total, 78.4% of all isolates are marked ‘first weighted’ - 50.1% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
<p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, there’s a shortcut for this new algorithm too:</p>
<div class="sourceCode" id="cb19"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">&lt;-</span> <span class="no">data</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</pre></body></html></div>
<p>So we end up with 15,684 isolates for analysis.</p>
<p>So we end up with 15,673 isolates for analysis.</p>
<p>We can remove unneeded columns:</p>
<div class="sourceCode" id="cb20"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">&lt;-</span> <span class="no">data_1st</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(-<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="no">first</span>, <span class="no">keyab</span>))</pre></body></html></div>
@ -797,56 +793,56 @@ Longest: 1</p> @@ -797,56 +793,56 @@ Longest: 1</p>
<tbody>
<tr class="odd">
<td>1</td>
<td align="center">2013-03-27</td>
<td align="center">L8</td>
<td align="center">Hospital B</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">2015-03-17</td>
<td align="center">U1</td>
<td align="center">Hospital D</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</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">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">TRUE</td>
</tr>
<tr class="even">
<td>2</td>
<td align="center">2015-12-30</td>
<td align="center">K1</td>
<td align="center">2017-08-02</td>
<td align="center">P6</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AURS</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">R</td>
<td align="center">F</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>3</td>
<td align="center">2016-06-06</td>
<td align="center">D3</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AURS</td>
<td align="center">S</td>
<td align="center">S</td>
<td>4</td>
<td align="center">2011-02-12</td>
<td align="center">I10</td>
<td align="center">Hospital D</td>
<td align="center">B_STRPT_PNMN</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">M</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>4</td>
<td align="center">2011-07-04</td>
<td align="center">H10</td>
<td>6</td>
<td align="center">2010-08-19</td>
<td align="center">A7</td>
<td align="center">Hospital D</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
@ -860,35 +856,35 @@ Longest: 1</p> @@ -860,35 +856,35 @@ Longest: 1</p>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>6</td>
<td align="center">2017-03-06</td>
<td align="center">S4</td>
<td align="center">Hospital C</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">S</td>
<td>7</td>
<td align="center">2013-04-06</td>
<td align="center">H5</td>
<td align="center">Hospital A</td>
<td align="center">B_STPHY_AURS</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-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>
<tr class="even">
<td>7</td>
<td align="center">2014-08-08</td>
<td align="center">C5</td>
<td>8</td>
<td align="center">2013-12-11</td>
<td align="center">J8</td>
<td align="center">Hospital C</td>
<td align="center">B_ESCHR_COLI</td>
<td align="center">B_KLBSL_PNMN</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">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>
</tbody>
@ -910,8 +906,8 @@ Longest: 1</p> @@ -910,8 +906,8 @@ Longest: 1</p>
<div class="sourceCode" id="cb23"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="no">genus</span>, <span class="no">species</span>)</pre></body></html></div>
<p><strong>Frequency table</strong></p>
<p>Class: character<br>
Length: 15,684<br>
Available: 15,684 (100%, NA: 0 = 0%)<br>
Length: 15,673<br>
Available: 15,673 (100%, NA: 0 = 0%)<br>
Unique: 4</p>
<p>Shortest: 16<br>
Longest: 24</p>
@ -928,33 +924,33 @@ Longest: 24</p> @@ -928,33 +924,33 @@ Longest: 24</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Escherichia coli</td>
<td align="right">7,819</td>
<td align="right">49.85%</td>
<td align="right">7,819</td>
<td align="right">49.85%</td>
<td align="right">7,843</td>
<td align="right">50.04%</td>
<td align="right">7,843</td>
<td align="right">50.04%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Staphylococcus aureus</td>
<td align="right">3,992</td>
<td align="right">25.45%</td>
<td align="right">11,811</td>
<td align="right">75.31%</td>
<td align="right">3,949</td>
<td align="right">25.20%</td>
<td align="right">11,792</td>
<td align="right">75.24%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td>
<td align="right">2,332</td>
<td align="right">14.87%</td>
<td align="right">14,143</td>
<td align="right">90.17%</td>
<td align="right">2,320</td>
<td align="right">14.80%</td>
<td align="right">14,112</td>
<td align="right">90.04%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td>
<td align="right">1,541</td>
<td align="right">9.83%</td>
<td align="right">15,684</td>
<td align="right">1,561</td>
<td align="right">9.96%</td>
<td align="right">15,673</td>
<td align="right">100.00%</td>
</tr>
</tbody>
@ -966,7 +962,7 @@ Longest: 24</p> @@ -966,7 +962,7 @@ Longest: 24</p>
<p>The functions <code><a href="../reference/proportion.html">resistance()</a></code> and <code><a href="../reference/proportion.html">susceptibility()</a></code> can be used to calculate antimicrobial resistance or susceptibility. For more specific analyses, the functions <code><a href="../reference/proportion.html">proportion_S()</a></code>, <code><a href="../reference/proportion.html">proportion_SI()</a></code>, <code><a href="../reference/proportion.html">proportion_I()</a></code>, <code><a href="../reference/proportion.html">proportion_IR()</a></code> and <code><a href="../reference/proportion.html">proportion_R()</a></code> can be used to determine the proportion of a specific antimicrobial outcome.</p>
<p>As per the EUCAST guideline of 2019, we calculate resistance as the proportion of R (<code><a href="../reference/proportion.html">proportion_R()</a></code>, equal to <code><a href="../reference/proportion.html">resistance()</a></code>) and susceptibility as the proportion of S and I (<code><a href="../reference/proportion.html">proportion_SI()</a></code>, equal to <code><a href="../reference/proportion.html">susceptibility()</a></code>). These functions can be used on their own:</p>
<div class="sourceCode" id="cb24"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">%&gt;%</span> <span class="fu"><a href="../reference/proportion.html">resistance</a></span>(<span class="no">AMX</span>)
<span class="co"># [1] 0.4410227</span></pre></body></html></div>
<span class="co"># [1] 0.441396</span></pre></body></html></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="cb25"><html><body><pre class="r"><span class="no">data_1st</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(<span class="no">hospital</span>) <span class="kw">%&gt;%</span>
@ -979,19 +975,19 @@ Longest: 24</p> @@ -979,19 +975,19 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4448217</td>
<td align="center">0.4339461</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4476345</td>
<td align="center">0.4463033</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4299828</td>
<td align="center">0.4511013</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4317450</td>
<td align="center">0.4368288</td>
</tr>
</tbody>
</table>
@ -1009,23 +1005,23 @@ Longest: 24</p> @@ -1009,23 +1005,23 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4448217</td>
<td align="center">4712</td>
<td align="center">0.4339461</td>
<td align="center">4678</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4476345</td>
<td align="center">5538</td>
<td align="center">0.4463033</td>
<td align="center">5559</td>
</tr>
<tr class="odd">
<td align=