mirror of
https://github.com/msberends/AMR.git
synced 2026-05-31 20:21:47 +02:00
Built site for AMR@3.0.1.9057: 0af3f84
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
|
||||
|
||||
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9055</small>
|
||||
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9057</small>
|
||||
|
||||
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
@@ -98,7 +98,7 @@
|
||||
|
||||
|
||||
<dt id="arg-as-mic">as.mic<a class="anchor" aria-label="anchor" href="#arg-as-mic"></a></dt>
|
||||
<dd><p>A <a href="https://rdrr.io/r/base/logical.html" class="external-link">logical</a> to indicate whether the <code>mic</code> class should be kept - the default is <code>TRUE</code> for <code>rescale_mic()</code> and <code>FALSE</code> for <code><a href="https://rdrr.io/pkg/data.table/man/fdroplevels.html" class="external-link">droplevels()</a></code>. When setting this to <code>FALSE</code> in <code>rescale_mic()</code>, the output will have factor levels that acknowledge <code>mic_range</code>.</p></dd>
|
||||
<dd><p>A [logical] to indicate whether the `mic` class should be kept - the default is `TRUE` for [rescale_mic()] and `FALSE` for [droplevels()]. When setting this to `FALSE` in [rescale_mic()], the output will have factor levels that acknowledge `mic_range`.</p></dd>
|
||||
|
||||
|
||||
<dt id="arg--">...<a class="anchor" aria-label="anchor" href="#arg--"></a></dt>
|
||||
@@ -107,45 +107,45 @@
|
||||
</dl></div>
|
||||
<div class="section level2">
|
||||
<h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
|
||||
<p>Ordered <a href="https://rdrr.io/pkg/data.table/man/fctr.html" class="external-link">factor</a> with additional class <code>mic</code>, that in mathematical operations acts as a <a href="https://rdrr.io/r/base/numeric.html" class="external-link">numeric</a> vector. Bear in mind that the outcome of any mathematical operation on MICs will return a <a href="https://rdrr.io/r/base/numeric.html" class="external-link">numeric</a> value.</p>
|
||||
<p>Ordered [factor] with additional class [`mic`], that in mathematical operations acts as a [numeric] vector. Bear in mind that the outcome of any mathematical operation on MICs will return a [numeric] value.</p>
|
||||
</div>
|
||||
<div class="section level2">
|
||||
<h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
|
||||
<p>To interpret MIC values as SIR values, use <code><a href="as.sir.html">as.sir()</a></code> on MIC values. It supports guidelines from EUCAST (2011-2026) and CLSI (2011-2026).</p>
|
||||
<p>This class for MIC values is a quite a special data type: formally it is an ordered <a href="https://rdrr.io/pkg/data.table/man/fctr.html" class="external-link">factor</a> with valid MIC values as <a href="https://rdrr.io/pkg/data.table/man/fctr.html" class="external-link">factor</a> levels (to make sure only valid MIC values are retained), but for any mathematical operation it acts as decimal numbers:</p>
|
||||
<p></p><div class="sourceCode"><pre><code><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a>x <span class="ot"><-</span> <span class="fu">random_mic</span>(<span class="dv">10</span>)</span>
|
||||
<span id="cb1-2"><a href="#cb1-2" tabindex="-1"></a>x</span>
|
||||
<span id="cb1-3"><a href="#cb1-3" tabindex="-1"></a><span class="co">#> Class <mic></span></span>
|
||||
<span id="cb1-4"><a href="#cb1-4" tabindex="-1"></a><span class="co">#> [1] 16 1 8 8 64 >=128 0.0625 32 32 16</span></span>
|
||||
<span id="cb1-5"><a href="#cb1-5" tabindex="-1"></a></span>
|
||||
<span id="cb1-6"><a href="#cb1-6" tabindex="-1"></a><span class="fu">is.factor</span>(x)</span>
|
||||
<span id="cb1-7"><a href="#cb1-7" tabindex="-1"></a><span class="co">#> [1] TRUE</span></span>
|
||||
<span id="cb1-8"><a href="#cb1-8" tabindex="-1"></a></span>
|
||||
<span id="cb1-9"><a href="#cb1-9" tabindex="-1"></a>x[<span class="dv">1</span>] <span class="sc">*</span> <span class="dv">2</span></span>
|
||||
<span id="cb1-10"><a href="#cb1-10" tabindex="-1"></a><span class="co">#> [1] 32</span></span>
|
||||
<span id="cb1-11"><a href="#cb1-11" tabindex="-1"></a></span>
|
||||
<span id="cb1-12"><a href="#cb1-12" tabindex="-1"></a><span class="fu">median</span>(x)</span>
|
||||
<span id="cb1-13"><a href="#cb1-13" tabindex="-1"></a><span class="co">#> [1] 26</span></span></code></pre><p></p></div>
|
||||
<p>This makes it possible to maintain operators that often come with MIC values, such ">=" and "<=", even when filtering using <a href="https://rdrr.io/r/base/numeric.html" class="external-link">numeric</a> values in data analysis, e.g.:</p>
|
||||
<p></p><div class="sourceCode"><pre><code><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a>x[x <span class="sc">></span> <span class="dv">4</span>]</span>
|
||||
<span id="cb1-2"><a href="#cb1-2" tabindex="-1"></a><span class="co">#> Class <mic></span></span>
|
||||
<span id="cb1-3"><a href="#cb1-3" tabindex="-1"></a><span class="co">#> [1] 16 8 8 64 >=128 32 32 16</span></span>
|
||||
<span id="cb1-4"><a href="#cb1-4" tabindex="-1"></a></span>
|
||||
<span id="cb1-5"><a href="#cb1-5" tabindex="-1"></a>df <span class="ot"><-</span> <span class="fu">data.frame</span>(x, <span class="at">hospital =</span> <span class="st">"A"</span>)</span>
|
||||
<span id="cb1-6"><a href="#cb1-6" tabindex="-1"></a><span class="fu">subset</span>(df, x <span class="sc">></span> <span class="dv">4</span>) <span class="co"># or with dplyr: df %>% filter(x > 4)</span></span>
|
||||
<span id="cb1-7"><a href="#cb1-7" tabindex="-1"></a><span class="co">#> x hospital</span></span>
|
||||
<span id="cb1-8"><a href="#cb1-8" tabindex="-1"></a><span class="co">#> 1 16 A</span></span>
|
||||
<span id="cb1-9"><a href="#cb1-9" tabindex="-1"></a><span class="co">#> 5 64 A</span></span>
|
||||
<span id="cb1-10"><a href="#cb1-10" tabindex="-1"></a><span class="co">#> 6 >=128 A</span></span>
|
||||
<span id="cb1-11"><a href="#cb1-11" tabindex="-1"></a><span class="co">#> 8 32 A</span></span>
|
||||
<span id="cb1-12"><a href="#cb1-12" tabindex="-1"></a><span class="co">#> 9 32 A</span></span>
|
||||
<span id="cb1-13"><a href="#cb1-13" tabindex="-1"></a><span class="co">#> 10 16 A</span></span></code></pre><p></p></div>
|
||||
<p>All so-called <a href="https://rdrr.io/r/base/groupGeneric.html" class="external-link">group generic functions</a> are implemented for the MIC class (such as <code>!</code>, <code>!=</code>, <code><</code>, <code>>=</code>, <code><a href="https://rdrr.io/r/base/Log.html" class="external-link">exp()</a></code>, <code><a href="https://rdrr.io/r/base/Log.html" class="external-link">log2()</a></code>). Some mathematical functions are also implemented (such as <code><a href="https://rdrr.io/r/stats/quantile.html" class="external-link">quantile()</a></code>, <code><a href="https://rdrr.io/r/stats/median.html" class="external-link">median()</a></code>, <code><a href="https://rdrr.io/r/stats/fivenum.html" class="external-link">fivenum()</a></code>). Since <code><a href="https://rdrr.io/r/stats/sd.html" class="external-link">sd()</a></code> and <code><a href="https://rdrr.io/r/stats/cor.html" class="external-link">var()</a></code> are non-generic functions, these could not be extended. Use <code><a href="https://rdrr.io/r/stats/mad.html" class="external-link">mad()</a></code> as an alternative, or use e.g. <code>sd(as.numeric(x))</code> where <code>x</code> is your vector of MIC values.</p>
|
||||
<p>Using <code><a href="https://rdrr.io/r/base/double.html" class="external-link">as.double()</a></code> or <code><a href="https://rdrr.io/r/base/numeric.html" class="external-link">as.numeric()</a></code> on MIC values will remove the operators and return a numeric vector. Do <strong>not</strong> use <code><a href="https://rdrr.io/r/base/integer.html" class="external-link">as.integer()</a></code> on MIC values as by the <span style="R">R</span> convention on <a href="https://rdrr.io/pkg/data.table/man/fctr.html" class="external-link">factor</a>s, it will return the index of the factor levels (which is often useless for regular users).</p>
|
||||
<p>The function <code>is.mic()</code> detects if the input contains class <code>mic</code>. If the input is a <a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a> or <a href="https://rdrr.io/r/base/list.html" class="external-link">list</a>, it iterates over all columns/items and returns a <a href="https://rdrr.io/r/base/logical.html" class="external-link">logical</a> vector.</p>
|
||||
<p>Use <code><a href="https://rdrr.io/pkg/data.table/man/fdroplevels.html" class="external-link">droplevels()</a></code> to drop unused levels. At default, it will return a plain factor. Use <code>droplevels(..., as.mic = TRUE)</code> to maintain the <code>mic</code> class.</p>
|
||||
<p>With <code>rescale_mic()</code>, existing MIC ranges can be limited to a defined range of MIC values. This can be useful to better compare MIC distributions.</p>
|
||||
<p>For <code>ggplot2</code>, use one of the <code><a href="plot.html">scale_*_mic()</a></code> functions to plot MIC values. They allows custom MIC ranges and to plot intermediate log2 levels for missing MIC values.</p>
|
||||
<p>To interpret MIC values as SIR values, use [as.sir()] on MIC values. It supports guidelines from EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline <!-- %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(clinical_breakpoints, guideline %like% "CLSI")$guideline)))`). --></p>
|
||||
<p>This class for MIC values is a quite a special data type: formally it is an ordered [factor] with valid MIC values as [factor] levels (to make sure only valid MIC values are retained), but for any mathematical operation it acts as decimal numbers:</p>
|
||||
<p>“`
|
||||
x <- random_mic(10)
|
||||
x
|
||||
#> Class <mic>
|
||||
#> [1] 16 1 8 8 64 >=128 0.0625 32 32 16</p>
|
||||
<p>is.factor(x)
|
||||
#> [1] TRUE</p>
|
||||
<p>x[1] * 2
|
||||
#> [1] 32</p>
|
||||
<p>median(x)
|
||||
#> [1] 26
|
||||
“`</p>
|
||||
<p>This makes it possible to maintain operators that often come with MIC values, such ">=" and "<=", even when filtering using [numeric] values in data analysis, e.g.:</p>
|
||||
<p>“`
|
||||
x[x > 4]
|
||||
#> Class <mic>
|
||||
#> [1] 16 8 8 64 >=128 32 32 16</p>
|
||||
<p>df <- data.frame(x, hospital = "A")
|
||||
subset(df, x > 4) # or with dplyr: df <!-- %>% filter(x > 4) -->
|
||||
#> x hospital
|
||||
#> 1 16 A
|
||||
#> 5 64 A
|
||||
#> 6 >=128 A
|
||||
#> 8 32 A
|
||||
#> 9 32 A
|
||||
#> 10 16 A
|
||||
“`</p>
|
||||
<p>All so-called [group generic functions][groupGeneric()] are implemented for the MIC class (such as `!`, `!=`, `<`, `>=`, [exp()], [log2()]). Some mathematical functions are also implemented (such as [quantile()], [median()], [fivenum()]). Since [sd()] and [var()] are non-generic functions, these could not be extended. Use [mad()] as an alternative, or use e.g. `sd(as.numeric(x))` where `x` is your vector of MIC values.</p>
|
||||
<p>Using [as.double()] or [as.numeric()] on MIC values will remove the operators and return a numeric vector. Do **not** use [as.integer()] on MIC values as by the <span style="R">R</span> convention on [factor]s, it will return the index of the factor levels (which is often useless for regular users).</p>
|
||||
<p>The function [is.mic()] detects if the input contains class `mic`. If the input is a [data.frame] or [list], it iterates over all columns/items and returns a [logical] vector.</p>
|
||||
<p>Use [droplevels()] to drop unused levels. At default, it will return a plain factor. Use `droplevels(..., as.mic = TRUE)` to maintain the `mic` class.</p>
|
||||
<p>With [rescale_mic()], existing MIC ranges can be limited to a defined range of MIC values. This can be useful to better compare MIC distributions.</p>
|
||||
<p>For `ggplot2`, use one of the [`scale_*_mic()`][scale_x_mic()] functions to plot MIC values. They allows custom MIC ranges and to plot intermediate log2 levels for missing MIC values.</p>
|
||||
<p><code>NA_mic_</code> is a missing value of the new <code>mic</code> class, analogous to e.g. base <span style="R">R</span>'s <code><a href="https://rdrr.io/r/base/NA.html" class="external-link">NA_character_</a></code>.</p>
|
||||
<p>Use <code>mic_p50()</code> and <code>mic_p90()</code> to get the 50th and 90th percentile of MIC values. They return 'normal' <a href="https://rdrr.io/r/base/numeric.html" class="external-link">numeric</a> values.</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user