<!-- Generated by pkgdown: do not edit by hand --><htmllang="en"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><metacharset="utf-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metaname="viewport"content="width=device-width, initial-scale=1.0"><title>(Key) Antimicrobials for First Weighted Isolates — key_antimicrobials • AMR (for R)</title><!-- favicons --><linkrel="icon"type="image/png"sizes="16x16"href="../favicon-16x16.png"><linkrel="icon"type="image/png"sizes="32x32"href="../favicon-32x32.png"><linkrel="apple-touch-icon"type="image/png"sizes="180x180"href="../apple-touch-icon.png"><linkrel="apple-touch-icon"type="image/png"sizes="120x120"href="../apple-touch-icon-120x120.png"><linkrel="apple-touch-icon"type="image/png"sizes="76x76"href="../apple-touch-icon-76x76.png"><linkrel="apple-touch-icon"type="image/png"sizes="60x60"href="../apple-touch-icon-60x60.png"><!-- jquery --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="crossorigin="anonymous"></script><!-- Bootstrap --><linkhref="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css"rel="stylesheet"crossorigin="anonymous"><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js"integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4="crossorigin="anonymous"></script><!-- bootstrap-toc --><linkrel="stylesheet"href="../bootstrap-toc.css"><scriptsrc="../bootstrap-toc.js"></script><!-- Font Awesome icons --><linkrel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css"integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk="crossorigin="anonymous"><linkrel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css"integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw="crossorigin="anonymous"><!-- clipboard.js --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js"integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI="crossorigin="anonymous"></script><!-- headroom.js --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js"integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0="crossorigin="anonymous"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js"integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4="crossorigin="anonymous"></script><!-- pkgdown --><linkhref="../pkgdown.css"rel="stylesheet"><scriptsrc="../pkgdown.js"></script><linkhref="../extra.css"rel="stylesheet"><scriptsrc="../extra.js"></script><metaproperty="og:title"content="(Key) Antimicrobials for First Weighted Isolates — key_antimicrobials"><metaproperty="og:description"content="These functions can be used to determine first weighted isolates by considering the phenotype for isolate selection (see first_isolate()). Using a phenotype-based method to determine first isolates is more reliable than methods that disregard phenotypes."><metaproperty="og:image"content="https://msberends.github.io/AMR/logo.svg"><metaname="twitter:card"content="summary_large_image"><metaname="twitter:creator"content="@msberends"><metaname="twitter:site"content="@univgroningen"><!-- mathjax --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k="crossorigin="anonymous"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js"integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA="crossorigin="anonymous"></script><!--[if lt IE 9]>
<p>These functions can be used to determine first weighted isolates by considering the phenotype for isolate selection (see <code><ahref="first_isolate.html">first_isolate()</a></code>). Using a phenotype-based method to determine first isolates is more reliable than methods that disregard phenotypes.</p>
<span> type <spanclass="op">=</span><spanclass="fu"><ahref="https://rdrr.io/r/base/c.html"class="external-link">c</a></span><spanclass="op">(</span><spanclass="st">"points"</span>, <spanclass="st">"keyantimicrobials"</span><spanclass="op">)</span>,</span>
<dd><p>a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> with antibiotics columns, like <code>AMX</code> or <code>amox</code>. Can be left blank to determine automatically</p></dd>
<dd><p>column name of the IDs of the microorganisms (see <code><ahref="as.mo.html">as.mo()</a></code>), defaults to the first column of class <code><ahref="as.mo.html">mo</a></code>. Values will be coerced using <code><ahref="as.mo.html">as.mo()</a></code>.</p></dd>
<dd><p>names of <strong>broad-spectrum</strong> antimicrobial agents, case-insensitive. Set to <code>NULL</code> to ignore. See <em>Details</em> for the default agents.</p></dd>
<dd><p>names of antibiotic agents for <strong>Gram-positives</strong>, case-insensitive. Set to <code>NULL</code> to ignore. See <em>Details</em> for the default agents.</p></dd>
<dd><p>names of antibiotic agents for <strong>Gram-negatives</strong>, case-insensitive. Set to <code>NULL</code> to ignore. See <em>Details</em> for the default agents.</p></dd>
<dd><p>names of antifungal agents for <strong>fungi</strong>, case-insensitive. Set to <code>NULL</code> to ignore. See <em>Details</em> for the default agents.</p></dd>
<dd><p>a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate whether only columns must be included that were transformed to class <code><rsi></code> (see <code><ahref="as.rsi.html">as.rsi()</a></code>) on beforehand (defaults to <code>FALSE</code>)</p></dd>
<dd><p><ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate whether antibiotic interpretations with <code>"I"</code> will be ignored when <code>type = "keyantimicrobials"</code>, see <em>Details</em></p></dd>
<dd><p>minimum number of points to require before differences in the antibiogram will lead to inclusion of an isolate when <code>type = "points"</code>, see <em>Details</em></p></dd>
<p>The <code>key_antimicrobials()</code> and <code>all_antimicrobials()</code> functions are context-aware. This means that the <code>x</code> argument can be left blank if used inside a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> call, see <em>Examples</em>.</p>
<p>The function <code>key_antimicrobials()</code> returns a <ahref="https://rdrr.io/r/base/character.html"class="external-link">character</a> vector with 12 antimicrobial results for every isolate. The function <code>all_antimicrobials()</code> returns a <ahref="https://rdrr.io/r/base/character.html"class="external-link">character</a> vector with all antimicrobial results for every isolate. These vectors can then be compared using <code>antimicrobials_equal()</code>, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (<code>"."</code>) by <code>key_antimicrobials()</code> and ignored by <code>antimicrobials_equal()</code>.</p>
<p>Please see the <code><ahref="first_isolate.html">first_isolate()</a></code> function how these important functions enable the 'phenotype-based' method for determination of first isolates.</p>
<p>The default antimicrobial agents used for <strong>all rows</strong> (set in <code>universal</code>) are:</p><ul><li><p>Ampicillin</p></li>
</ul><p>The default antimicrobial agents used for <strong>Gram-negative bacteria</strong> (set in <code>gram_negative</code>) are:</p><ul><li><p>Cefotaxime</p></li>
</ul><p>The default antimicrobial agents used for <strong>Gram-positive bacteria</strong> (set in <code>gram_positive</code>) are:</p><ul><li><p>Erythromycin</p></li>
The <ahref="lifecycle.html">lifecycle</a> of this function is <strong>stable</strong>. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.</p>
<p>If the unlying code needs breaking changes, they will occur gradually. For example, an argument will be deprecated and first continue to work, but will emit a message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.</p>
<p>On our website <ahref="https://msberends.github.io/AMR/">https://msberends.github.io/AMR/</a> you can find <ahref="https://msberends.github.io/AMR/articles/AMR.html">a comprehensive tutorial</a> about how to conduct AMR data analysis, the <ahref="https://msberends.github.io/AMR/reference/">complete documentation of all functions</a> and <ahref="https://msberends.github.io/AMR/articles/WHONET.html">an example analysis using WHONET data</a>.</p>
<divclass="sourceCode"><preclass="sourceCode r"><code><span><spanclass="co"># `example_isolates` is a data set available in the AMR package.</span></span>
<span><spanclass="co"># See ?example_isolates.</span></span>
<span></span>
<span><spanclass="co"># output of the `key_antimicrobials()` function could be like this:</span></span>
<span><spanclass="co"># those strings can be compared with:</span></span>
<span><spanclass="fu">antimicrobials_equal</span><spanclass="op">(</span><spanclass="va">strainA</span>, <spanclass="va">strainB</span>, type <spanclass="op">=</span><spanclass="st">"keyantimicrobials"</span><spanclass="op">)</span></span>
<span><spanclass="co"># TRUE, because I is ignored (as well as missing values)</span></span>
<span></span>
<span><spanclass="fu">antimicrobials_equal</span><spanclass="op">(</span><spanclass="va">strainA</span>, <spanclass="va">strainB</span>, type <spanclass="op">=</span><spanclass="st">"keyantimicrobials"</span>, ignore_I <spanclass="op">=</span><spanclass="cn">FALSE</span><spanclass="op">)</span></span>
<span><spanclass="co"># FALSE, because I is not ignored and so the 4th [character] differs</span></span>
<span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/mutate.html"class="external-link">mutate</a></span><spanclass="op">(</span>keyab <spanclass="op">=</span><spanclass="fu">key_antimicrobials</span><spanclass="op">(</span>antifungal <spanclass="op">=</span><spanclass="cn">NULL</span><spanclass="op">)</span><spanclass="op">)</span><spanclass="op"><ahref="https://magrittr.tidyverse.org/reference/pipe.html"class="external-link">%>%</a></span><spanclass="co"># no need to define `x`</span></span>