1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 08:46:12 +01:00

freq update

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-02-12 15:38:31 +01:00
parent 76ed26d27e
commit 30ff770c93
12 changed files with 333 additions and 330 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 0.5.0.9017
Date: 2019-02-11
Date: 2019-02-12
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(

View File

@ -564,8 +564,16 @@ format_header <- function(x, markdown = FALSE, decimal.mark = ".", big.mark = ",
# FORMATTING
# rsi
if (has_length == TRUE & any(x_class == "rsi")) {
if (header$count_S < header$count_IR) {
ratio <- paste0(green(1), ":", red(format(header$count_IR / header$count_S,
digits = 1, nsmall = 1, decimal.mark = decimal.mark, big.mark = big.mark)))
} else {
ratio <- paste0(green(format(header$count_S / header$count_IR,
digits = 1, nsmall = 1, decimal.mark = decimal.mark, big.mark = big.mark)),
":", red(1))
}
header$`%IR` <- paste((header$count_IR / header$length) %>% percent(force_zero = TRUE, round = digits, decimal.mark = decimal.mark),
paste0("(ratio S : IR = 1.0 : ", (header$count_IR / header$count_S) %>% format(digits = 1, nsmall = 1, decimal.mark = decimal.mark, big.mark = big.mark), ")"))
paste0("(ratio ", ratio, ")"))
header <- header[!names(header) %in% c("count_S", "count_IR")]
}
# dates
@ -872,11 +880,20 @@ print.frequency_tbl <- function(x,
if (opt$tbl_format == "pandoc") {
title <- bold(title)
} else if (opt$tbl_format == "markdown") {
title <- paste0("\n**", title, "** ") # two space for newline
title <- paste0("\n\n**", title, "** ") # two space for newline
}
cat(title, "\n\n")
if (NROW(x) == 0) {
cat("No observations.\n")
if (opt$tbl_format == "markdown") {
cat("\n")
}
return(invisible())
}
if (opt$header == TRUE) {
cat(title, "\n")
if (!is.null(opt$header_txt)) {
if (is.null(opt$digits)) {
opt$digits <- 2
@ -884,14 +901,6 @@ print.frequency_tbl <- function(x,
cat(format_header(x, digits = opt$digits, markdown = (opt$tbl_format == "markdown"),
decimal.mark = decimal.mark, big.mark = big.mark))
}
} else if (opt$tbl_format == "markdown") {
# do print title as caption in markdown
cat("\n", title, sep = "") # two trailing spaces for markdown
}
if (NROW(x) == 0) {
cat("\n\nNo observations.\n")
return(invisible())
}
# save old NA setting for kable

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -185,7 +185,7 @@
<h1>How to apply EUCAST rules</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">11 February 2019</h4>
<h4 class="date">12 February 2019</h4>
<div class="hidden name"><code>EUCAST.Rmd</code></div>

View File

@ -185,7 +185,7 @@
<h1>How to get properties of an antibiotic</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">11 February 2019</h4>
<h4 class="date">12 February 2019</h4>
<div class="hidden name"><code>atc_property.Rmd</code></div>

View File

@ -185,7 +185,7 @@
<h1>How to get properties of a microorganism</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">11 February 2019</h4>
<h4 class="date">12 February 2019</h4>
<div class="hidden name"><code>mo_property.Rmd</code></div>

View File

@ -185,7 +185,7 @@
<h1>How to predict antimicrobial resistance</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">11 February 2019</h4>
<h4 class="date">12 February 2019</h4>
<div class="hidden name"><code>resistance_predict.Rmd</code></div>
@ -295,7 +295,7 @@
<a href="#choosing-the-right-model" class="anchor"></a>Choosing the right model</h3>
<p>Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" title="1">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-2" title="2"><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/filter">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"vanc"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>()</a>
<a class="sourceLine" id="cb8-5" title="5"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
@ -340,7 +340,7 @@
</table>
<p>For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on the observed years:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" title="1">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-2" title="2"><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/dplyr/topics/filter">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"vanc"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>, <span class="dt">model =</span> <span class="st">"linear"</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>()</a>
<a class="sourceLine" id="cb9-5" title="5"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>

View File

@ -798,7 +798,7 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
<ul>
<li>Full support for Windows, Linux and macOS</li>
<li>Full support for old R versions, only R-3.0.0 (April 2013) or later is needed (needed packages may have other dependencies)</li>
<li>Function <code>n_rsi</code> to count cases where antibiotic test results were available, to be used in conjunction with <code><a href="https://www.rdocumentation.org/packages/dplyr/topics/summarise">dplyr::summarise</a></code>, see ?rsi</li>
<li>Function <code>n_rsi</code> to count cases where antibiotic test results were available, to be used in conjunction with <code><a href="https://dplyr.tidyverse.org/reference/summarise.html">dplyr::summarise</a></code>, see ?rsi</li>
<li>Function <code>guess_bactid</code> to <strong>determine the ID</strong> of a microorganism based on genus/species or known abbreviations like MRSA</li>
<li>Function <code>guess_atc</code> to <strong>determine the ATC</strong> of an antibiotic based on name, trade name, or known abbreviations</li>
<li>Function <code>freq</code> to create <strong>frequency tables</strong>, with additional info in a header</li>