(v1.1.0.9007) lose dependencies

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-05-16 21:40:50 +02:00
parent 29609a0e2c
commit f68d71a5e0
44 changed files with 178 additions and 140 deletions

View File

@ -1,5 +1,5 @@
Package: AMR
Version: 1.1.0.9006
Version: 1.1.0.9007
Date: 2020-05-16
Title: Antimicrobial Resistance Analysis
Authors@R: c(

View File

@ -1,4 +1,4 @@
# AMR 1.1.0.9006
# AMR 1.1.0.9007
## <small>Last updated: 16-May-2020</small>
### Breaking

View File

@ -32,6 +32,7 @@
#' @examples
#' availability(example_isolates)
#'
#' \dontrun{
#' library(dplyr)
#' example_isolates %>% availability()
#'
@ -43,6 +44,7 @@
#' filter(mo == as.mo("E. coli")) %>%
#' select_if(is.rsi) %>%
#' availability()
#' }
availability <- function(tbl, width = NULL) {
x <- base::sapply(tbl, function(x) {
1 - base::sum(base::is.na(x)) / base::length(x)

View File

@ -69,7 +69,7 @@
#' susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
#'
#'
#' if (!require("dplyr")) {
#' if (require("dplyr")) {
#' example_isolates %>%
#' group_by(hospital_id) %>%
#' summarise(R = count_R(CIP),

View File

@ -33,6 +33,7 @@
#' @seealso [as.rsi()]
#' @inheritSection AMR Read more on our website!
#' @examples
#' \dontrun{
#' # transform existing disk zones to the `disk` class
#' library(dplyr)
#' df <- data.frame(microorganism = "E. coli",
@ -50,6 +51,7 @@
#' guideline = "EUCAST")
#'
#' as.rsi(df)
#' }
as.disk <- function(x, na.rm = FALSE) {
if (is.disk(x)) {
x

View File

@ -206,7 +206,8 @@ eucast_rules <- function(x,
"\n\nThis may overwrite your existing data if you use e.g.:",
"\ndata <- eucast_rules(data, verbose = TRUE)\n\nDo you want to continue?")
if ("rstudioapi" %in% rownames(utils::installed.packages())) {
q_continue <- rstudioapi::showQuestion("Using verbose = TRUE with eucast_rules()", txt)
showQuestion <- get("showQuestion", envir = asNamespace("rstudioapi"))
q_continue <- showQuestion("Using verbose = TRUE with eucast_rules()", txt)
} else {
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)
}

View File

@ -62,7 +62,7 @@
#' @export
#' @inheritSection AMR Read more on our website!
#' @examples
#' if (!require("ggplot2") & !require("dplyr")) {
#' if (require("ggplot2") & require("dplyr")) {
#'
#' # get antimicrobial results for drugs against a UTI:
#' ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) +

View File

@ -73,6 +73,7 @@
#' # `example_isolates` is a dataset available in the AMR package.
#' # See ?example_isolates.
#'
#' \dontrun{
#' library(dplyr)
#' # set key antibiotics to a new variable
#' my_patients <- example_isolates %>%
@ -87,7 +88,7 @@
#' # Check the difference, in this data set it results in 7% more isolates:
#' sum(my_patients$first_regular, na.rm = TRUE)
#' sum(my_patients$first_weighted, na.rm = TRUE)
#'
#' }
#'
#' # output of the `key_antibiotics` function could be like this:
#' strainA <- "SSSRR.S.R..S"

View File

@ -57,10 +57,12 @@
#' #> TRUE TRUE TRUE
#'
#' # get isolates whose name start with 'Ent' or 'ent'
#' \dontrun{
#' library(dplyr)
#' example_isolates %>%
#' filter(mo_name(mo) %like% "^ent") %>%
#' freq(mo)
#' }
like <- function(x, pattern, ignore.case = TRUE) {
# set to fixed if no regex found
fixed <- all(!grepl("[$.^*?+}{|)(]", pattern))

View File

@ -66,7 +66,7 @@
#' @source
#' Please see *Details* for the list of publications used for this function.
#' @examples
#' \donttest{
#' \dontrun{
#' library(dplyr)
#'
#' example_isolates %>%
@ -94,7 +94,8 @@ mdro <- function(x,
"\n\nThis may overwrite your existing data if you use e.g.:",
"\ndata <- mdro(data, verbose = TRUE)\n\nDo you want to continue?")
if ("rstudioapi" %in% rownames(utils::installed.packages())) {
q_continue <- rstudioapi::showQuestion("Using verbose = TRUE with mdro()", txt)
showQuestion <- get("showQuestion", envir = asNamespace("rstudioapi"))
q_continue <- showQuestion("Using verbose = TRUE with mdro()", txt)
} else {
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)
}

View File

@ -126,7 +126,8 @@ set_mo_source <- function(path) {
} else if (path %like% "[.]xlsx?$") {
# is Excel file (old or new)
stopifnot_installed_package("readxl")
df <- readxl::read_excel(path)
read_excel <- get("read_excel", envir = asNamespace("readxl"))
df <- read_excel(path)
} else if (path %like% "[.]tsv$") {
df <- utils::read.table(header = TRUE, sep = "\t", stringsAsFactors = FALSE)

View File

@ -99,8 +99,7 @@
#' proportion_IR(example_isolates$AMX)
#' proportion_R(example_isolates$AMX)
#'
#' if (!require("dplyr")) {
#' library(dplyr)
#' if (require("dplyr")) {
#' example_isolates %>%
#' group_by(hospital_id) %>%
#' summarise(r = resistance(CIP),
@ -157,7 +156,9 @@
#' select(hospital_id, AMX, CIP) %>%
#' group_by(hospital_id) %>%
#' proportion_df(translate = FALSE)
#'
#' }
#'
#' \dontrun{
#' # calculate current empiric combination therapy of Helicobacter gastritis:
#' my_table %>%
#' filter(first_isolate == TRUE,

View File

@ -66,11 +66,12 @@
#' year_min = 2010,
#' model = "binomial")
#' plot(x)
#' ggplot_rsi_predict(x)
#' if (require("ggplot2")) {
#' ggplot_rsi_predict(x)
#' }
#'
#' # using dplyr:
#' if (!require("dplyr")) {
#' library(dplyr)
#' if (require("dplyr")) {
#' x <- example_isolates %>%
#' filter_first_isolate() %>%
#' filter(mo_genus(mo) == "Staphylococcus") %>%
@ -83,7 +84,7 @@
#' }
#'
#' # create nice plots with ggplot2 yourself
#' if (!require(ggplot2) & !require("dplyr")) {
#' if (require(ggplot2) & require("dplyr")) {
#'
#' data <- example_isolates %>%
#' filter(mo == as.mo("E. coli")) %>%

View File

@ -70,7 +70,7 @@
#' NIT = as.mic(32))
#' as.rsi(df)
#'
#' \donttest{
#' \dontrun{
#'
#' # the dplyr way
#' library(dplyr)
@ -117,6 +117,7 @@
#' plot(rsi_data) # for percentages
#' barplot(rsi_data) # for frequencies
#'
#' \dontrun{
#' library(dplyr)
#' example_isolates %>%
#' mutate_at(vars(PEN:RIF), as.rsi)
@ -132,6 +133,7 @@
#' # default threshold of `is.rsi.eligible` is 5%.
#' is.rsi.eligible(WHONET$`First name`) # fails, >80% is invalid
#' is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds
#' }
as.rsi <- function(x, ...) {
UseMethod("as.rsi")
}

View File

@ -23,7 +23,7 @@
init:
ps: |
$ErrorActionPreference = "Stop"
Invoke-WebRequest https://gitlab.com/msberends/AMR/raw/master/tests/appveyor/appveyor_tool.ps1 -OutFile "..\appveyor-tool.ps1"
Invoke-WebRequest https://gitlab.com/msberends/AMR/raw/premaster/tests/appveyor/appveyor_tool.ps1 -OutFile "..\appveyor-tool.ps1"
Import-Module '..\appveyor-tool.ps1'
install:

View File

@ -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.9005</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>

View File

@ -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.9005</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>

View File

@ -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.9005</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>

View File

@ -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.9005</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>

View File

@ -43,7 +43,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.9005</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>

View File

@ -10,7 +10,7 @@ articles:
WHONET: WHONET.html
benchmarks: benchmarks.html
resistance_predict: resistance_predict.html
last_built: 2020-05-16T18:05Z
last_built: 2020-05-16T19:39Z
urls:
reference: https://msberends.gitlab.io/AMR/reference
article: https://msberends.gitlab.io/AMR/articles

View File

@ -82,7 +82,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</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -275,7 +275,8 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<div class='dont-index'><p><code><a href='as.rsi.html'>as.rsi()</a></code></p></div>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># transform existing disk zones to the `disk` class</span>
<pre class="examples"><span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># transform existing disk zones to the `disk` class</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(<span class='kw'>microorganism</span> <span class='kw'>=</span> <span class='st'>"E. coli"</span>,
<span class='kw'>AMP</span> <span class='kw'>=</span> <span class='fl'>20</span>,
@ -291,7 +292,8 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='kw'>ab</span> <span class='kw'>=</span> <span class='st'>"ampicillin"</span>, <span class='co'># and `ab` with as.ab()</span>
<span class='kw'>guideline</span> <span class='kw'>=</span> <span class='st'>"EUCAST"</span>)
<span class='fu'><a href='as.rsi.html'>as.rsi</a></span>(<span class='no'>df</span>)</pre>
<span class='fu'><a href='as.rsi.html'>as.rsi</a></span>(<span class='no'>df</span>)
}</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">
@ -307,7 +309,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
</div>
</footer>

View File

@ -82,7 +82,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.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -353,7 +353,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='kw'>NIT</span> <span class='kw'>=</span> <span class='fu'><a href='as.mic.html'>as.mic</a></span>(<span class='fl'>32</span>))
<span class='fu'>as.rsi</span>(<span class='no'>df</span>)
<span class='co'># \donttest{</span>
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># the dplyr way</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
@ -376,7 +376,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='no'>df</span> <span class='kw'>%&gt;%</span>
<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'>AMP</span>:<span class='no'>NIT</span>), <span class='no'>as.rsi</span>, <span class='kw'>mo</span> <span class='kw'>=</span> <span class='st'>"E. coli"</span>, <span class='kw'>uti</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
<span class='co'># }</span>
}
<span class='co'># for single values</span>
<span class='fu'>as.rsi</span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='fu'><a href='as.mic.html'>as.mic</a></span>(<span class='fl'>2</span>),
@ -400,6 +400,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='fu'><a href='https://rdrr.io/r/base/plot.html'>plot</a></span>(<span class='no'>rsi_data</span>) <span class='co'># for percentages</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/barplot.html'>barplot</a></span>(<span class='no'>rsi_data</span>) <span class='co'># for frequencies</span>
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<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'>PEN</span>:<span class='no'>RIF</span>), <span class='no'>as.rsi</span>)
@ -414,7 +415,8 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='co'># default threshold of `is.rsi.eligible` is 5%.</span>
<span class='fu'>is.rsi.eligible</span>(<span class='no'>WHONET</span>$<span class='no'>`First name`</span>) <span class='co'># fails, &gt;80% is invalid</span>
<span class='fu'>is.rsi.eligible</span>(<span class='no'>WHONET</span>$<span class='no'>`First name`</span>, <span class='kw'>threshold</span> <span class='kw'>=</span> <span class='fl'>0.99</span>) <span class='co'># succeeds</span></pre>
<span class='fu'>is.rsi.eligible</span>(<span class='no'>WHONET</span>$<span class='no'>`First name`</span>, <span class='kw'>threshold</span> <span class='kw'>=</span> <span class='fl'>0.99</span>) <span class='co'># succeeds</span>
}</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">

View File

@ -83,7 +83,7 @@ This function requires an internet connection." />
</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</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -315,7 +315,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>questioni
<p>On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># \donttest{</span>
<pre class="examples"><span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># oral DDD (Defined Daily Dose) of amoxicillin</span>
<span class='fu'>atc_online_property</span>(<span class='st'>"J01CA04"</span>, <span class='st'>"DDD"</span>, <span class='st'>"O"</span>)
<span class='co'># parenteral DDD (Defined Daily Dose) of amoxicillin</span>
@ -326,7 +326,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>questioni
<span class='co'># [2] "ANTIBACTERIALS FOR SYSTEMIC USE"</span>
<span class='co'># [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS"</span>
<span class='co'># [4] "Penicillins with extended spectrum"</span>
<span class='co'># }</span></pre>
}</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">
@ -342,7 +342,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>questioni
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
</div>
</footer>

View File

@ -82,7 +82,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</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -272,6 +272,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='fu'>availability</span>(<span class='no'>example_isolates</span>)
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>availability</span>()
@ -282,7 +283,8 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>mo</span> <span class='kw'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select_all.html'>select_if</a></span>(<span class='no'>is.rsi</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>availability</span>()</pre>
<span class='fu'>availability</span>()
}</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">
@ -298,7 +300,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p>
</div>
</footer>

View File

@ -83,7 +83,7 @@ count_resistant() should be used to count resistant isolates, count_susceptible(
</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.9005</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -392,7 +392,7 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
<span class='fu'><a href='proportion.html'>susceptibility</a></span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) * <span class='fu'>n_rsi</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='kw'>if</span> (!<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"dplyr"</span>)) {
<span class='kw'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"dplyr"</span>)) {
<span class='no'>example_isolates</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_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>R</span> <span class='kw'>=</span> <span class='fu'>count_R</span>(<span class='no'>CIP</span>),

View File

@ -82,7 +82,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.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -412,44 +412,45 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>maturing<
<p>On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>ggplot2</span>)
<pre class="examples"><span class='kw'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"ggplot2"</span>) <span class='kw'>&amp;</span> <span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"dplyr"</span>)) {
<span class='co'># get antimicrobial results for drugs against a UTI:</span>
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)) +
<span class='fu'>geom_rsi</span>()
<span class='co'># get antimicrobial results for drugs against a UTI:</span>
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)) +
<span class='fu'>geom_rsi</span>()
<span class='co'># prettify the plot using some additional functions:</span>
<span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>df</span>) +
<span class='fu'>geom_rsi</span>() +
<span class='fu'>scale_y_percent</span>() +
<span class='fu'>scale_rsi_colours</span>() +
<span class='fu'>labels_rsi_count</span>() +
<span class='fu'>theme_rsi</span>()
<span class='co'># prettify the plot using some additional functions:</span>
<span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>df</span>) +
<span class='fu'>geom_rsi</span>() +
<span class='fu'>scale_y_percent</span>() +
<span class='fu'>scale_rsi_colours</span>() +
<span class='fu'>labels_rsi_count</span>() +
<span class='fu'>theme_rsi</span>()
<span class='co'># or better yet, simplify this using the wrapper function - a single command:</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>()
<span class='co'># or better yet, simplify this using the wrapper function - a single command:</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>()
<span class='co'># get only proportions and no counts:</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>datalabels</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
<span class='co'># get only proportions and no counts:</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>datalabels</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
<span class='co'># add other ggplot2 parameters as you like:</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>width</span> <span class='kw'>=</span> <span class='fl'>0.5</span>,
<span class='kw'>colour</span> <span class='kw'>=</span> <span class='st'>"black"</span>,
<span class='kw'>size</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>linetype</span> <span class='kw'>=</span> <span class='fl'>2</span>,
<span class='kw'>alpha</span> <span class='kw'>=</span> <span class='fl'>0.25</span>)
<span class='co'># add other ggplot2 parameters as you like:</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>width</span> <span class='kw'>=</span> <span class='fl'>0.5</span>,
<span class='kw'>colour</span> <span class='kw'>=</span> <span class='st'>"black"</span>,
<span class='kw'>size</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>linetype</span> <span class='kw'>=</span> <span class='fl'>2</span>,
<span class='kw'>alpha</span> <span class='kw'>=</span> <span class='fl'>0.25</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>colours</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>SI</span> <span class='kw'>=</span> <span class='st'>"yellow"</span>))
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>colours</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='kw'>SI</span> <span class='kw'>=</span> <span class='st'>"yellow"</span>))
}
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {

View File

@ -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.9005</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>

View File

@ -82,7 +82,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.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -388,6 +388,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<pre class="examples"><span class='co'># `example_isolates` is a dataset available in the AMR package.</span>
<span class='co'># See ?example_isolates.</span>
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='co'># set key antibiotics to a new variable</span>
<span class='no'>my_patients</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
@ -402,7 +403,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='co'># Check the difference, in this data set it results in 7% more isolates:</span>
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='no'>my_patients</span>$<span class='no'>first_regular</span>, <span class='kw'>na.rm</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='no'>my_patients</span>$<span class='no'>first_weighted</span>, <span class='kw'>na.rm</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
}
<span class='co'># output of the `key_antibiotics` function could be like this:</span>
<span class='no'>strainA</span> <span class='kw'>&lt;-</span> <span class='st'>"SSSRR.S.R..S"</span>

View File

@ -82,7 +82,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.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -306,10 +306,12 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='co'>#&gt; TRUE TRUE TRUE</span>
<span class='co'># get isolates whose name start with 'Ent' or 'ent'</span>
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'><a href='mo_property.html'>mo_name</a></span>(<span class='no'>mo</span>) <span class='kw'>%like%</span> <span class='st'>"^ent"</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'>mo</span>)</pre>
<span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>(<span class='no'>mo</span>)
}</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">

View File

@ -82,7 +82,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.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -440,7 +440,7 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
<p>On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># \donttest{</span>
<pre class="examples"><span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
@ -451,7 +451,7 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>EUCAST</span> <span class='kw'>=</span> <span class='fu'>eucast_exceptional_phenotypes</span>(<span class='no'>.</span>),
<span class='kw'>BRMO</span> <span class='kw'>=</span> <span class='fu'>brmo</span>(<span class='no'>.</span>),
<span class='kw'>MRGN</span> <span class='kw'>=</span> <span class='fu'>mrgn</span>(<span class='no'>.</span>))
<span class='co'># }</span></pre>
}</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">

View File

@ -83,7 +83,7 @@ resistance() should be used to calculate resistance, susceptibility() should be
</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.9005</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -398,8 +398,7 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
<span class='fu'>proportion_IR</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='fu'>proportion_R</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='kw'>if</span> (!<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"dplyr"</span>)) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='kw'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"dplyr"</span>)) {
<span class='no'>example_isolates</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_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>r</span> <span class='kw'>=</span> <span class='fu'>resistance</span>(<span class='no'>CIP</span>),
@ -456,7 +455,9 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>hospital_id</span>, <span class='no'>AMX</span>, <span class='no'>CIP</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_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>proportion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
}
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># calculate current empiric combination therapy of Helicobacter gastritis:</span>
<span class='no'>my_table</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_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>,

View File

@ -82,7 +82,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.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0.9007</span>
</span>
</div>
@ -393,11 +393,12 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
<span class='kw'>year_min</span> <span class='kw'>=</span> <span class='fl'>2010</span>,
<span class='kw'>model</span> <span class='kw'>=</span> <span class='st'>"binomial"</span>)
<span class='fu'><a href='https://rdrr.io/r/base/plot.html'>plot</a></span>(<span class='no'>x</span>)
<span class='fu'>ggplot_rsi_predict</span>(<span class='no'>x</span>)
<span class='kw'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"ggplot2"</span>)) {
<span class='fu'>ggplot_rsi_predict</span>(<span class='no'>x</span>)
}
<span class='co'># using dplyr:</span>
<span class='kw'>if</span> (!<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"dplyr"</span>)) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='kw'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"dplyr"</span>)) {
<span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='first_isolate.html'>filter_first_isolate</a></span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='no'>mo</span>) <span class='kw'>==</span> <span class='st'>"Staphylococcus"</span>) <span class='kw'>%&gt;%</span>
@ -410,7 +411,7 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
}
<span class='co'># create nice plots with ggplot2 yourself</span>
<span class='kw'>if</span> (!<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='no'>ggplot2</span>) <span class='kw'>&amp;</span> !<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"dplyr"</span>)) {
<span class='kw'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='no'>ggplot2</span>) <span class='kw'>&amp;</span> <span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'>"dplyr"</span>)) {
<span class='no'>data</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>mo</span> <span class='kw'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='kw'>%&gt;%</span>

View File

@ -38,6 +38,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
\dontrun{
# transform existing disk zones to the `disk` class
library(dplyr)
df <- data.frame(microorganism = "E. coli",
@ -56,6 +57,7 @@ as.rsi(x = as.disk(18),
as.rsi(df)
}
}
\seealso{
\code{\link[=as.rsi]{as.rsi()}}
}

View File

@ -110,7 +110,7 @@ df <- data.frame(microorganism = "E. coli",
NIT = as.mic(32))
as.rsi(df)
\donttest{
\dontrun{
# the dplyr way
library(dplyr)
@ -157,6 +157,7 @@ is.rsi(rsi_data)
plot(rsi_data) # for percentages
barplot(rsi_data) # for frequencies
\dontrun{
library(dplyr)
example_isolates \%>\%
mutate_at(vars(PEN:RIF), as.rsi)
@ -173,6 +174,7 @@ example_isolates \%>\%
is.rsi.eligible(WHONET$`First name`) # fails, >80\% is invalid
is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds
}
}
\seealso{
\code{\link[=as.mic]{as.mic()}}
}

View File

@ -75,7 +75,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
\donttest{
\dontrun{
# oral DDD (Defined Daily Dose) of amoxicillin
atc_online_property("J01CA04", "DDD", "O")
# parenteral DDD (Defined Daily Dose) of amoxicillin

View File

@ -36,6 +36,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
\examples{
availability(example_isolates)
\dontrun{
library(dplyr)
example_isolates \%>\% availability()
@ -48,3 +49,4 @@ example_isolates \%>\%
select_if(is.rsi) \%>\%
availability()
}
}

View File

@ -158,7 +158,7 @@ count_susceptible(example_isolates$AMX)
susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
if (!require("dplyr")) {
if (require("dplyr")) {
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(R = count_R(CIP),

View File

@ -147,44 +147,45 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
library(dplyr)
library(ggplot2)
# get antimicrobial results for drugs against a UTI:
ggplot(example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)) +
geom_rsi()
# prettify the plot using some additional functions:
df <- example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)
ggplot(df) +
geom_rsi() +
scale_y_percent() +
scale_rsi_colours() +
labels_rsi_count() +
theme_rsi()
# or better yet, simplify this using the wrapper function - a single command:
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi()
# get only proportions and no counts:
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi(datalabels = FALSE)
# add other ggplot2 parameters as you like:
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi(width = 0.5,
colour = "black",
size = 1,
linetype = 2,
alpha = 0.25)
example_isolates \%>\%
select(AMX) \%>\%
ggplot_rsi(colours = c(SI = "yellow"))
if (require("ggplot2") & require("dplyr")) {
# get antimicrobial results for drugs against a UTI:
ggplot(example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)) +
geom_rsi()
# prettify the plot using some additional functions:
df <- example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)
ggplot(df) +
geom_rsi() +
scale_y_percent() +
scale_rsi_colours() +
labels_rsi_count() +
theme_rsi()
# or better yet, simplify this using the wrapper function - a single command:
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi()
# get only proportions and no counts:
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi(datalabels = FALSE)
# add other ggplot2 parameters as you like:
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi(width = 0.5,
colour = "black",
size = 1,
linetype = 2,
alpha = 0.25)
example_isolates \%>\%
select(AMX) \%>\%
ggplot_rsi(colours = c(SI = "yellow"))
}
\dontrun{

View File

@ -136,6 +136,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
# `example_isolates` is a dataset available in the AMR package.
# See ?example_isolates.
\dontrun{
library(dplyr)
# set key antibiotics to a new variable
my_patients <- example_isolates \%>\%
@ -150,7 +151,7 @@ my_patients <- example_isolates \%>\%
# Check the difference, in this data set it results in 7\% more isolates:
sum(my_patients$first_regular, na.rm = TRUE)
sum(my_patients$first_weighted, na.rm = TRUE)
}
# output of the `key_antibiotics` function could be like this:
strainA <- "SSSRR.S.R..S"

View File

@ -68,11 +68,13 @@ a \%like\% b
#> TRUE TRUE TRUE
# get isolates whose name start with 'Ent' or 'ent'
\dontrun{
library(dplyr)
example_isolates \%>\%
filter(mo_name(mo) \%like\% "^ent") \%>\%
freq(mo)
}
}
\seealso{
\code{\link[base:grep]{base::grep()}}
}

View File

@ -206,7 +206,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
\donttest{
\dontrun{
library(dplyr)
example_isolates \%>\%

View File

@ -160,8 +160,7 @@ proportion_I(example_isolates$AMX)
proportion_IR(example_isolates$AMX)
proportion_R(example_isolates$AMX)
if (!require("dplyr")) {
library(dplyr)
if (require("dplyr")) {
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(r = resistance(CIP),
@ -218,7 +217,9 @@ if (!require("dplyr")) {
select(hospital_id, AMX, CIP) \%>\%
group_by(hospital_id) \%>\%
proportion_df(translate = FALSE)
}
\dontrun{
# calculate current empiric combination therapy of Helicobacter gastritis:
my_table \%>\%
filter(first_isolate == TRUE,

View File

@ -132,11 +132,12 @@ x <- resistance_predict(example_isolates,
year_min = 2010,
model = "binomial")
plot(x)
ggplot_rsi_predict(x)
if (require("ggplot2")) {
ggplot_rsi_predict(x)
}
# using dplyr:
if (!require("dplyr")) {
library(dplyr)
if (require("dplyr")) {
x <- example_isolates \%>\%
filter_first_isolate() \%>\%
filter(mo_genus(mo) == "Staphylococcus") \%>\%
@ -149,7 +150,7 @@ if (!require("dplyr")) {
}
# create nice plots with ggplot2 yourself
if (!require(ggplot2) & !require("dplyr")) {
if (require(ggplot2) & require("dplyr")) {
data <- example_isolates \%>\%
filter(mo == as.mo("E. coli")) \%>\%