mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 06:46:11 +01:00
(v1.6.0.9065) unit tests
This commit is contained in:
parent
4fbf9e1720
commit
e5599bc694
1
.github/workflows/check.yaml
vendored
1
.github/workflows/check.yaml
vendored
@ -121,6 +121,7 @@ jobs:
|
||||
# - name: Only keep vignettes on release version
|
||||
- name: Remove vignettes
|
||||
# if: matrix.config.r != 'release'
|
||||
if: always()
|
||||
# writing to DESCRIPTION2 and then moving to DESCRIPTION is required for R < 3.3 as writeLines() cannot overwrite
|
||||
run: |
|
||||
rm -rf AMR/vignettes
|
||||
|
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 1.6.0.9064
|
||||
Version: 1.6.0.9065
|
||||
Date: 2021-05-24
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Authors@R: c(
|
||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
||||
# `AMR` 1.6.0.9064
|
||||
# `AMR` 1.6.0.9065
|
||||
## <small>Last updated: 24 May 2021</small>
|
||||
|
||||
### Breaking change
|
||||
|
@ -864,8 +864,13 @@ unique_call_id <- function(entire_session = FALSE) {
|
||||
} else {
|
||||
# combination of environment ID (like "0x7fed4ee8c848")
|
||||
# and highest system call
|
||||
call <- paste0(deparse(sys.calls()[[1]]), collapse = "")
|
||||
if (call %like% "run_test_dir|test_all|tinytest|test_package|testthat") {
|
||||
# unit tests will keep the same call and environment - give them a unique ID
|
||||
call <- paste0(sample(c(c(0:9), letters[1:6]), size = 64, replace = TRUE), collapse = "")
|
||||
}
|
||||
c(envir = gsub("<environment: (.*)>", "\\1", utils::capture.output(sys.frames()[[1]])),
|
||||
call = paste0(deparse(sys.calls()[[1]]), collapse = ""))
|
||||
call = call)
|
||||
}
|
||||
}
|
||||
|
||||
@ -881,14 +886,6 @@ message_not_thrown_before <- function(fn, entire_session = FALSE) {
|
||||
is.null(pkg_env[[paste0("thrown_msg.", fn)]]) || !identical(pkg_env[[paste0("thrown_msg.", fn)]], unique_call_id(entire_session))
|
||||
}
|
||||
|
||||
reset_all_thrown_messages <- function() {
|
||||
# for unit tests, where the environment and highest system call do not change
|
||||
# can be found in tests/testthat/*.R
|
||||
pkg_env_contents <- ls(envir = pkg_env)
|
||||
rm(list = pkg_env_contents[pkg_env_contents %like% "^thrown_msg."],
|
||||
envir = pkg_env)
|
||||
}
|
||||
|
||||
has_colour <- function() {
|
||||
# this is a base R version of crayon::has_color, but disables colours on emacs
|
||||
|
||||
|
@ -115,35 +115,35 @@
|
||||
#' ggplot() +
|
||||
#' geom_col(aes(x = x, y = y, fill = z)) +
|
||||
#' scale_rsi_colours(Value4 = "S", Value5 = "I", Value6 = "R")
|
||||
#'
|
||||
#' # resistance of ciprofloxacine per age group
|
||||
#' example_isolates %>%
|
||||
#' mutate(first_isolate = first_isolate()) %>%
|
||||
#' filter(first_isolate == TRUE,
|
||||
#' mo == as.mo("E. coli")) %>%
|
||||
#' # age_groups() is also a function in this AMR package:
|
||||
#' group_by(age_group = age_groups(age)) %>%
|
||||
#' select(age_group,
|
||||
#' CIP) %>%
|
||||
#' ggplot_rsi(x = "age_group")
|
||||
#'
|
||||
#' # a shorter version which also adjusts data label colours:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi(colours = FALSE)
|
||||
#'
|
||||
#'
|
||||
#' # it also supports groups (don't forget to use the group var on `x` or `facet`):
|
||||
#' example_isolates %>%
|
||||
#' select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' ggplot_rsi(x = "hospital_id",
|
||||
#' facet = "antibiotic",
|
||||
#' nrow = 1,
|
||||
#' title = "AMR of Anti-UTI Drugs Per Hospital",
|
||||
#' x.title = "Hospital",
|
||||
#' datalabels = FALSE)
|
||||
#' }
|
||||
#'
|
||||
#' # resistance of ciprofloxacine per age group
|
||||
#' example_isolates %>%
|
||||
#' mutate(first_isolate = first_isolate(.)) %>%
|
||||
#' filter(first_isolate == TRUE,
|
||||
#' mo == as.mo("E. coli")) %>%
|
||||
#' # age_groups() is also a function in this AMR package:
|
||||
#' group_by(age_group = age_groups(age)) %>%
|
||||
#' select(age_group,
|
||||
#' CIP) %>%
|
||||
#' ggplot_rsi(x = "age_group")
|
||||
#'
|
||||
#' # a shorter version which also adjusts data label colours:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi(colours = FALSE)
|
||||
#'
|
||||
#'
|
||||
#' # it also supports groups (don't forget to use the group var on `x` or `facet`):
|
||||
#' example_isolates %>%
|
||||
#' select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' ggplot_rsi(x = "hospital_id",
|
||||
#' facet = "antibiotic",
|
||||
#' nrow = 1,
|
||||
#' title = "AMR of Anti-UTI Drugs Per Hospital",
|
||||
#' x.title = "Hospital",
|
||||
#' datalabels = FALSE)
|
||||
#' }
|
||||
ggplot_rsi <- function(data,
|
||||
position = NULL,
|
||||
|
Binary file not shown.
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9064</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9064</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9064</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9064</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9064</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -42,7 +42,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.6.0.9064</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9064</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -236,9 +236,9 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1609064" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0.9064">
|
||||
<a href="#amr-1609064" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9064</h1>
|
||||
<div id="amr-1609065" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0.9065">
|
||||
<a href="#amr-1609065" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9065</h1>
|
||||
<div id="last-updated-24-may-2021" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#last-updated-24-may-2021" class="anchor"></a><small>Last updated: 24 May 2021</small>
|
||||
@ -288,7 +288,7 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li>Function <code><a href="../reference/antibiotic_class_selectors.html">betalactams()</a></code> as additional antbiotic column selector and function <code><a href="../reference/AMR-deprecated.html">filter_betalactams()</a></code> as additional antbiotic column filter. The group of betalactams consists of all carbapenems, cephalosporins and penicillins.</li>
|
||||
<li>A <code>ggplot()</code> method for <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>
|
||||
<li>A <code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot()</a></code> method for <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -387,7 +387,7 @@
|
||||
<span class="co">#> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"</span></code></pre></div>
|
||||
</li>
|
||||
<li><p>Support for custom MDRO guidelines, using the new <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function, please see <code><a href="../reference/mdro.html">mdro()</a></code> for additional info</p></li>
|
||||
<li><p><code>ggplot()</code> generics for classes <code><mic></code> and <code><disk></code></p></li>
|
||||
<li><p><code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot()</a></code> generics for classes <code><mic></code> and <code><disk></code></p></li>
|
||||
<li>
|
||||
<p>Function <code><a href="../reference/mo_property.html">mo_is_yeast()</a></code>, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||
@ -444,7 +444,7 @@
|
||||
<li>Plotting of MIC and disk diffusion values now support interpretation colouring if you supply the microorganism and antimicrobial agent</li>
|
||||
<li>All colours were updated to colour-blind friendly versions for values R, S and I for all plot methods (also applies to tibble printing)</li>
|
||||
<li>Interpretation of MIC and disk diffusion values to R/SI will now be translated if the system language is German, Dutch or Spanish (see <code>translate</code>)</li>
|
||||
<li>Plotting is now possible with base R using <code><a href="../reference/plot.html">plot()</a></code> and with ggplot2 using <code>ggplot()</code> on any vector of MIC and disk diffusion values</li>
|
||||
<li>Plotting is now possible with base R using <code><a href="../reference/plot.html">plot()</a></code> and with ggplot2 using <code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot()</a></code> on any vector of MIC and disk diffusion values</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Updated SNOMED codes to US Edition of SNOMED CT from 1 September 2020 and added the source to the help page of the <code>microorganisms</code> data set</li>
|
||||
|
@ -12,7 +12,7 @@ articles:
|
||||
datasets: datasets.html
|
||||
resistance_predict: resistance_predict.html
|
||||
welcome_to_AMR: welcome_to_AMR.html
|
||||
last_built: 2021-05-24T07:33Z
|
||||
last_built: 2021-05-24T09:00Z
|
||||
urls:
|
||||
reference: https://msberends.github.io/AMR//reference
|
||||
article: https://msberends.github.io/AMR//articles
|
||||
|
@ -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.6.0.9063</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -477,35 +477,35 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
|
||||
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span><span class='op'>(</span><span class='op'>)</span> <span class='op'>+</span>
|
||||
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/geom_bar.html'>geom_col</a></span><span class='op'>(</span><span class='fu'><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span><span class='op'>(</span>x <span class='op'>=</span> <span class='va'>x</span>, y <span class='op'>=</span> <span class='va'>y</span>, fill <span class='op'>=</span> <span class='va'>z</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>+</span>
|
||||
<span class='fu'>scale_rsi_colours</span><span class='op'>(</span>Value4 <span class='op'>=</span> <span class='st'>"S"</span>, Value5 <span class='op'>=</span> <span class='st'>"I"</span>, Value6 <span class='op'>=</span> <span class='st'>"R"</span><span class='op'>)</span>
|
||||
|
||||
<span class='co'># resistance of ciprofloxacine per age group</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span><span class='op'>(</span>first_isolate <span class='op'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='va'>first_isolate</span> <span class='op'>==</span> <span class='cn'>TRUE</span>,
|
||||
<span class='va'>mo</span> <span class='op'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span><span class='op'>(</span><span class='st'>"E. coli"</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='co'># age_groups() is also a function in this AMR package:</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span><span class='op'>(</span>age_group <span class='op'>=</span> <span class='fu'><a href='age_groups.html'>age_groups</a></span><span class='op'>(</span><span class='va'>age</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>age_group</span>,
|
||||
<span class='va'>CIP</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'>ggplot_rsi</span><span class='op'>(</span>x <span class='op'>=</span> <span class='st'>"age_group"</span><span class='op'>)</span>
|
||||
|
||||
<span class='co'># a shorter version which also adjusts data label colours:</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>AMX</span>, <span class='va'>NIT</span>, <span class='va'>FOS</span>, <span class='va'>TMP</span>, <span class='va'>CIP</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'>ggplot_rsi</span><span class='op'>(</span>colours <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
|
||||
|
||||
<span class='co'># it also supports groups (don't forget to use the group var on `x` or `facet`):</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>hospital_id</span>, <span class='va'>AMX</span>, <span class='va'>NIT</span>, <span class='va'>FOS</span>, <span class='va'>TMP</span>, <span class='va'>CIP</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span><span class='op'>(</span><span class='va'>hospital_id</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'>ggplot_rsi</span><span class='op'>(</span>x <span class='op'>=</span> <span class='st'>"hospital_id"</span>,
|
||||
facet <span class='op'>=</span> <span class='st'>"antibiotic"</span>,
|
||||
nrow <span class='op'>=</span> <span class='fl'>1</span>,
|
||||
title <span class='op'>=</span> <span class='st'>"AMR of Anti-UTI Drugs Per Hospital"</span>,
|
||||
x.title <span class='op'>=</span> <span class='st'>"Hospital"</span>,
|
||||
datalabels <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
<span class='op'>}</span>
|
||||
|
||||
<span class='co'># resistance of ciprofloxacine per age group</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span><span class='op'>(</span>first_isolate <span class='op'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span><span class='op'>(</span><span class='va'>.</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='va'>first_isolate</span> <span class='op'>==</span> <span class='cn'>TRUE</span>,
|
||||
<span class='va'>mo</span> <span class='op'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span><span class='op'>(</span><span class='st'>"E. coli"</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='co'># age_groups() is also a function in this AMR package:</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span><span class='op'>(</span>age_group <span class='op'>=</span> <span class='fu'><a href='age_groups.html'>age_groups</a></span><span class='op'>(</span><span class='va'>age</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>age_group</span>,
|
||||
<span class='va'>CIP</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'>ggplot_rsi</span><span class='op'>(</span>x <span class='op'>=</span> <span class='st'>"age_group"</span><span class='op'>)</span>
|
||||
|
||||
<span class='co'># a shorter version which also adjusts data label colours:</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>AMX</span>, <span class='va'>NIT</span>, <span class='va'>FOS</span>, <span class='va'>TMP</span>, <span class='va'>CIP</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'>ggplot_rsi</span><span class='op'>(</span>colours <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
|
||||
|
||||
<span class='co'># it also supports groups (don't forget to use the group var on `x` or `facet`):</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>hospital_id</span>, <span class='va'>AMX</span>, <span class='va'>NIT</span>, <span class='va'>FOS</span>, <span class='va'>TMP</span>, <span class='va'>CIP</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span><span class='op'>(</span><span class='va'>hospital_id</span><span class='op'>)</span> <span class='op'>%>%</span>
|
||||
<span class='fu'>ggplot_rsi</span><span class='op'>(</span>x <span class='op'>=</span> <span class='st'>"hospital_id"</span>,
|
||||
facet <span class='op'>=</span> <span class='st'>"antibiotic"</span>,
|
||||
nrow <span class='op'>=</span> <span class='fl'>1</span>,
|
||||
title <span class='op'>=</span> <span class='st'>"AMR of Anti-UTI Drugs Per Hospital"</span>,
|
||||
x.title <span class='op'>=</span> <span class='st'>"Hospital"</span>,
|
||||
datalabels <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
<span class='co'># }</span>
|
||||
</pre>
|
||||
</div>
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9064</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9064</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9065</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -22,34 +22,32 @@
|
||||
# Visit our website for the full manual and a complete tutorial about #
|
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
||||
# ==================================================================== #
|
||||
|
||||
|
||||
expect_equal(AMR:::percentage(0.25), "25%")
|
||||
expect_equal(AMR:::percentage(0.5), "50%")
|
||||
expect_equal(AMR:::percentage(0.500, digits = 1), "50.0%")
|
||||
expect_equal(AMR:::percentage(0.1234), "12.3%")
|
||||
# round up 0.5
|
||||
# round up 0.5
|
||||
expect_equal(AMR:::percentage(0.0054), "0.5%")
|
||||
expect_equal(AMR:::percentage(0.0055), "0.6%")
|
||||
|
||||
|
||||
expect_equal(AMR:::strrep("A", 5), "AAAAA")
|
||||
expect_equal(AMR:::strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB"))
|
||||
expect_equal(AMR:::trimws(" test "), "test")
|
||||
expect_equal(AMR:::trimws(" test ", "l"), "test ")
|
||||
expect_equal(AMR:::trimws(" test ", "r"), " test")
|
||||
|
||||
|
||||
expect_warning(AMR:::generate_warning_abs_missing(c("AMP", "AMX")))
|
||||
expect_warning(AMR:::generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE))
|
||||
expect_warning(AMR:::get_column_abx(example_isolates, hard_dependencies = "FUS"))
|
||||
expect_message(AMR:::get_column_abx(example_isolates, soft_dependencies = "FUS"))
|
||||
if (AMR:::pkg_is_available("dplyr")) {
|
||||
|
||||
if (AMR:::pkg_is_available("dplyr")) {
|
||||
expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
|
||||
expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
|
||||
}
|
||||
|
||||
|
||||
# we rely on "grouped_tbl" being a class of grouped tibbles, so implement a test that checks for this:
|
||||
if (AMR:::pkg_is_available("dplyr")) {
|
||||
expect_true(AMR:::is_null_or_grouped_tbl(example_isolates %>% group_by(hospital_id)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# we rely on "grouped_tbl" being a class of grouped tibbles, so implement a test that checks for this:
|
||||
if (AMR:::pkg_is_available("dplyr")) {
|
||||
expect_true(AMR:::is_null_or_grouped_tbl(example_isolates %>% group_by(hospital_id)))
|
||||
}
|
||||
|
@ -36,11 +36,9 @@ expect_equal(count_R(example_isolates$AMX) + count_I(example_isolates$AMX),
|
||||
expect_equal(suppressWarnings(count_S(example_isolates$AMX)) + count_I(example_isolates$AMX),
|
||||
count_SI(example_isolates$AMX))
|
||||
|
||||
|
||||
# warning for speed loss
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(count_resistant(as.character(example_isolates$AMC)))
|
||||
AMR:::reset_all_thrown_messages()
|
||||
|
||||
expect_warning(count_resistant(example_isolates$AMC,
|
||||
as.character(example_isolates$GEN)))
|
||||
|
||||
|
@ -45,6 +45,7 @@ expect_warning(eucast_rules(data.frame(mo = "Escherichia coli", vancomycin = "S"
|
||||
|
||||
expect_identical(colnames(example_isolates),
|
||||
colnames(suppressWarnings(eucast_rules(example_isolates, info = FALSE))))
|
||||
|
||||
expect_stdout(suppressMessages(eucast_rules(example_isolates, info = TRUE)))
|
||||
|
||||
a <- data.frame(mo = c("Klebsiella pneumoniae",
|
||||
@ -84,7 +85,7 @@ if (AMR:::pkg_is_available("dplyr")) {
|
||||
"R")
|
||||
}
|
||||
|
||||
# Azithromycin and Clarythromycin must be equal to Erythromycin
|
||||
# azithromycin and clarythromycin must be equal to Erythromycin
|
||||
a <- suppressWarnings(as.rsi(eucast_rules(data.frame(mo = example_isolates$mo,
|
||||
ERY = example_isolates$ERY,
|
||||
AZM = as.rsi("R"),
|
||||
@ -117,18 +118,21 @@ if (AMR:::pkg_is_available("dplyr")) {
|
||||
expect_stdout(suppressWarnings(eucast_rules(example_isolates, verbose = TRUE, rules = "all", info = TRUE)))
|
||||
|
||||
# AmpC de-repressed cephalo mutants
|
||||
|
||||
expect_identical(
|
||||
eucast_rules(data.frame(mo = c("Escherichia coli", "Enterobacter cloacae"),
|
||||
cefotax = as.rsi(c("S", "S"))),
|
||||
ampc_cephalosporin_resistance = TRUE,
|
||||
info = FALSE)$cefotax,
|
||||
as.rsi(c("S", "R")))
|
||||
|
||||
expect_identical(
|
||||
eucast_rules(data.frame(mo = c("Escherichia coli", "Enterobacter cloacae"),
|
||||
cefotax = as.rsi(c("S", "S"))),
|
||||
ampc_cephalosporin_resistance = NA,
|
||||
info = FALSE)$cefotax,
|
||||
as.rsi(c("S", NA)))
|
||||
|
||||
expect_identical(
|
||||
eucast_rules(data.frame(mo = c("Escherichia coli", "Enterobacter cloacae"),
|
||||
cefotax = as.rsi(c("S", "S"))),
|
||||
|
@ -88,14 +88,12 @@ if (AMR:::pkg_is_available("dplyr")) {
|
||||
example_isolates$AMX %>% proportion_R())
|
||||
)
|
||||
}
|
||||
AMR:::reset_all_thrown_messages()
|
||||
|
||||
expect_warning(proportion_R(as.character(example_isolates$AMC)))
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_S(as.character(example_isolates$AMC)))
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_S(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
AMR:::reset_all_thrown_messages()
|
||||
|
||||
expect_warning(n_rsi(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_equal(suppressWarnings(n_rsi(as.character(example_isolates$AMC,
|
||||
@ -120,11 +118,8 @@ expect_identical(suppressWarnings(proportion_S(example_isolates$AMX, minimum = n
|
||||
NA_real_)
|
||||
|
||||
# warning for speed loss
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_R(as.character(example_isolates$GEN)))
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_I(as.character(example_isolates$GEN)))
|
||||
AMR:::reset_all_thrown_messages()
|
||||
expect_warning(proportion_S(example_isolates$AMC, as.character(example_isolates$GEN)))
|
||||
expect_error(proportion_df(c("A", "B", "C")))
|
||||
expect_error(proportion_df(example_isolates[, "date"]))
|
||||
|
@ -202,34 +202,34 @@ if (require("ggplot2") & require("dplyr")) {
|
||||
ggplot() +
|
||||
geom_col(aes(x = x, y = y, fill = z)) +
|
||||
scale_rsi_colours(Value4 = "S", Value5 = "I", Value6 = "R")
|
||||
}
|
||||
|
||||
# resistance of ciprofloxacine per age group
|
||||
example_isolates \%>\%
|
||||
mutate(first_isolate = first_isolate(.)) \%>\%
|
||||
filter(first_isolate == TRUE,
|
||||
mo == as.mo("E. coli")) \%>\%
|
||||
# age_groups() is also a function in this AMR package:
|
||||
group_by(age_group = age_groups(age)) \%>\%
|
||||
select(age_group,
|
||||
CIP) \%>\%
|
||||
ggplot_rsi(x = "age_group")
|
||||
# resistance of ciprofloxacine per age group
|
||||
example_isolates \%>\%
|
||||
mutate(first_isolate = first_isolate()) \%>\%
|
||||
filter(first_isolate == TRUE,
|
||||
mo == as.mo("E. coli")) \%>\%
|
||||
# age_groups() is also a function in this AMR package:
|
||||
group_by(age_group = age_groups(age)) \%>\%
|
||||
select(age_group,
|
||||
CIP) \%>\%
|
||||
ggplot_rsi(x = "age_group")
|
||||
|
||||
# a shorter version which also adjusts data label colours:
|
||||
example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi(colours = FALSE)
|
||||
# a shorter version which also adjusts data label colours:
|
||||
example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi(colours = FALSE)
|
||||
|
||||
|
||||
# it also supports groups (don't forget to use the group var on `x` or `facet`):
|
||||
example_isolates \%>\%
|
||||
select(hospital_id, AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
ggplot_rsi(x = "hospital_id",
|
||||
facet = "antibiotic",
|
||||
nrow = 1,
|
||||
title = "AMR of Anti-UTI Drugs Per Hospital",
|
||||
x.title = "Hospital",
|
||||
datalabels = FALSE)
|
||||
# it also supports groups (don't forget to use the group var on `x` or `facet`):
|
||||
example_isolates \%>\%
|
||||
select(hospital_id, AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
ggplot_rsi(x = "hospital_id",
|
||||
facet = "antibiotic",
|
||||
nrow = 1,
|
||||
title = "AMR of Anti-UTI Drugs Per Hospital",
|
||||
x.title = "Hospital",
|
||||
datalabels = FALSE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user