<!-- 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>Count Available Isolates — count • 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="Count Available Isolates — count"><metaproperty="og:description"content="Thesefunctionscanbeusedtocountresistant/susceptiblemicrobialisolates.Allfunctionssupportquasiquotationwithpipes,canbeusedinsummarise()fromthedplyrpackageandalsosupportgroupedvariables,seeExamples.
count_resistant() should be used to count resistant isolates, count_susceptible() should be used to count susceptible isolates."><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 count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in <code><ahref="https://dplyr.tidyverse.org/reference/summarise.html"class="external-link">summarise()</a></code> from the <code>dplyr</code> package and also support grouped variables, see <em>Examples</em>.</p>
<p><code>count_resistant()</code> should be used to count resistant isolates, <code>count_susceptible()</code> should be used to count susceptible isolates.</p>
<dd><p>one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with <code><ahref="as.rsi.html">as.rsi()</a></code> if needed.</p></dd>
<dt>only_all_tested</dt>
<dd><p>(for combination therapies, i.e. using more than one variable for <code>...</code>): a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate that isolates must be tested for all antibiotics, see section <em>Combination Therapy</em> below</p></dd>
<dt>data</dt>
<dd><p>a <ahref="https://rdrr.io/r/base/data.frame.html"class="external-link">data.frame</a> containing columns with class <code><ahref="as.rsi.html">rsi</a></code> (see <code><ahref="as.rsi.html">as.rsi()</a></code>)</p></dd>
<dt>translate_ab</dt>
<dd><p>a column name of the <ahref="antibiotics.html">antibiotics</a> data set to translate the antibiotic abbreviations to, using <code><ahref="ab_property.html">ab_property()</a></code></p></dd>
<dd><p>language of the returned text, defaults to system language (see <code><ahref="translate.html">get_AMR_locale()</a></code>) and can also be set with <code>getOption("AMR_locale")</code>. Use <code>language = NULL</code> or <code>language = ""</code> to prevent translation.</p></dd>
<dd><p>a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate whether all values of S and I must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the argument <code>combine_IR</code>, but this now follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. Default is <code>TRUE</code>.</p></dd>
<dt>combine_IR</dt>
<dd><p>a <ahref="https://rdrr.io/r/base/logical.html"class="external-link">logical</a> to indicate whether all values of I and R must be merged into one, so the output only consists of S vs. I+R (susceptible vs. non-susceptible). This is outdated, see argument <code>combine_SI</code>.</p></dd>
<p>These functions are meant to count isolates. Use the <code><ahref="proportion.html">resistance()</a></code>/<code><ahref="proportion.html">susceptibility()</a></code> functions to calculate microbial resistance/susceptibility.</p>
<p>The function <code>count_resistant()</code> is equal to the function <code>count_R()</code>. The function <code>count_susceptible()</code> is equal to the function <code>count_SI()</code>.</p>
<p>The function <code>n_rsi()</code> is an alias of <code>count_all()</code>. They can be used to count all available isolates, i.e. where all input antibiotics have an available result (S, I or R). Their use is equal to <code><ahref="https://dplyr.tidyverse.org/reference/n_distinct.html"class="external-link">n_distinct()</a></code>. Their function is equal to <code>count_susceptible(...) + count_resistant(...)</code>.</p>
<p>The function <code>count_df()</code> takes any variable from <code>data</code> that has an <code><ahref="as.rsi.html">rsi</a></code> class (created with <code><ahref="as.rsi.html">as.rsi()</a></code>) and counts the number of S's, I's and R's. It also supports grouped variables. The function <code><ahref="proportion.html">rsi_df()</a></code> works exactly like <code>count_df()</code>, but adds the percentage of S, I and R.</p>
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>In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories R and S/I as shown below (<ahref="https://www.eucast.org/newsiandr/"class="external-link">https://www.eucast.org/newsiandr/</a>).</p><ul><li><p><strong>R = Resistant</strong><br>
A microorganism is categorised as <em>Resistant</em> when there is a high likelihood of therapeutic failure even when there is increased exposure. Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.</p></li>
A microorganism is categorised as <em>Susceptible, standard dosing regimen</em>, when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.</p></li>
A microorganism is categorised as <em>Susceptible, Increased exposure</em> when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.</p></li>
</ul><p>This AMR package honours this (new) insight. Use <code><ahref="proportion.html">susceptibility()</a></code> (equal to <code><ahref="proportion.html">proportion_SI()</a></code>) to determine antimicrobial susceptibility and <code>count_susceptible()</code> (equal to <code>count_SI()</code>) to count susceptible isolates.</p>
<p>When using more than one variable for <code>...</code> (= combination therapy), use <code>only_all_tested</code> to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Drug A and Drug B, about how <code><ahref="proportion.html">susceptibility()</a></code> works to calculate the %SI:</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>
</div>
<divid="see-also">
<h2>See also</h2>
<divclass="dont-index"><p><code><ahref="proportion.html">proportion_*</a></code> to calculate microbial resistance and susceptibility.</p></div>
</div>
<divid="ref-examples">
<h2>Examples</h2>
<divclass="sourceCode"><preclass="sourceCode r"><code><spanclass="co"># example_isolates is a data set available in the AMR package.</span>
<spanclass="fu">count_susceptible</span><spanclass="op">(</span><spanclass="va">example_isolates</span><spanclass="op">$</span><spanclass="va">AMX</span><spanclass="op">)</span><spanclass="co"># counts "S" and "I"</span>
<spanclass="fu">count_all</span><spanclass="op">(</span><spanclass="va">example_isolates</span><spanclass="op">$</span><spanclass="va">AMX</span><spanclass="op">)</span><spanclass="co"># counts "S", "I" and "R"</span>
I <spanclass="op">=</span><spanclass="fu">count_I</span><spanclass="op">(</span><spanclass="va">CIP</span><spanclass="op">)</span>,
S <spanclass="op">=</span><spanclass="fu">count_S</span><spanclass="op">(</span><spanclass="va">CIP</span><spanclass="op">)</span>,
n1 <spanclass="op">=</span><spanclass="fu">count_all</span><spanclass="op">(</span><spanclass="va">CIP</span><spanclass="op">)</span>, <spanclass="co"># the actual total; sum of all three</span>
n2 <spanclass="op">=</span><spanclass="fu">n_rsi</span><spanclass="op">(</span><spanclass="va">CIP</span><spanclass="op">)</span>, <spanclass="co"># same - analogous to n_distinct</span>
total <spanclass="op">=</span><spanclass="fu"><ahref="https://dplyr.tidyverse.org/reference/context.html"class="external-link">n</a></span><spanclass="op">(</span><spanclass="op">)</span><spanclass="op">)</span><spanclass="co"># NOT the number of tested isolates!</span>