<!-- 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, shrink-to-fit=no"><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"><scriptsrc="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><metaname="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no"><linkhref="../deps/bootstrap-5.3.1/bootstrap.min.css"rel="stylesheet"><scriptsrc="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><linkhref="../deps/Lato-0.4.9/font.css"rel="stylesheet"><linkhref="../deps/Fira_Code-0.4.9/font.css"rel="stylesheet"><linkhref="../deps/font-awesome-6.5.2/css/all.min.css"rel="stylesheet"><linkhref="../deps/font-awesome-6.5.2/css/v4-shims.min.css"rel="stylesheet"><scriptsrc="../deps/headroom-0.11.0/headroom.min.js"></script><scriptsrc="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><scriptsrc="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><scriptsrc="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><scriptsrc="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><scriptsrc="../deps/search-1.0.0/fuse.min.js"></script><scriptsrc="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><scriptsrc="../pkgdown.js"></script><linkhref="../extra.css"rel="stylesheet"><scriptsrc="../extra.js"></script><metaproperty="og:title"content="Count Available Isolates — count"><metaname="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: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"></head><body>
<buttonclass="nav-link dropdown-toggle"type="button"id="dropdown-how-to"data-bs-toggle="dropdown"aria-expanded="false"aria-haspopup="true"><spanclass="fa fa-question-circle"></span> How to</button>
<ulclass="dropdown-menu"aria-labelledby="dropdown-how-to"><li><aclass="dropdown-item"href="../articles/AMR.html"><spanclass="fa fa-directions"></span> Conduct AMR Analysis</a></li>
<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>
<span> language <spanclass="op">=</span><spanclass="fu"><ahref="translate.html">get_AMR_locale</a></span><spanclass="op">(</span><spanclass="op">)</span>,</span>
<dd><p>one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with <code><ahref="as.sir.html">as.sir()</a></code> if needed.</p></dd>
<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>
<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.sir.html">sir</a></code> (see <code><ahref="as.sir.html">as.sir()</a></code>)</p></dd>
<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 - the default is the current system language (see <code><ahref="translate.html">get_AMR_locale()</a></code>) and can also be set with the package option <code><ahref="AMR-options.html">AMR_locale</a></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, SDD, and I must be merged into one, so the output only consists of S+SDD+I vs. R (susceptible vs. resistant) - the default is <code>TRUE</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_sir()</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.sir.html">sir</a></code> class (created with <code><ahref="as.sir.html">as.sir()</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">sir_df()</a></code> works exactly like <code>count_df()</code>, but adds the percentage of S, I and R.</p>
<p>In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I, and R as shown below (<ahref="https://www.eucast.org/newsiandr"class="external-link">https://www.eucast.org/newsiandr</a>):</p><ul><li><p><strong>S - Susceptible, standard dosing regimen</strong><br>
A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.</p></li>
A microorganism is categorised as "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>
<li><p><strong>R = Resistant</strong><br>
A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.</p><ul><li><p><em>Exposure</em> 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>
</ul><p>This AMR package honours this 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>
<spanid="cb1-7"><ahref="#cb1-7"tabindex="-1"></a> S or I S or I X X X X</span>
<spanid="cb1-8"><ahref="#cb1-8"tabindex="-1"></a> R S or I X X X X</span>
<spanid="cb1-9"><ahref="#cb1-9"tabindex="-1"></a><spanclass="sc"><</span><spanclass="cn">NA</span><spanclass="sc">></span> S or I X X <spanclass="sc">-</span><spanclass="sc">-</span></span>
<spanid="cb1-10"><ahref="#cb1-10"tabindex="-1"></a> S or I R X X X X</span>
<spanid="cb1-11"><ahref="#cb1-11"tabindex="-1"></a> R R <spanclass="sc">-</span> X <spanclass="sc">-</span> X</span>
<spanid="cb1-12"><ahref="#cb1-12"tabindex="-1"></a><spanclass="sc"><</span><spanclass="cn">NA</span><spanclass="sc">></span> R <spanclass="sc">-</span><spanclass="sc">-</span><spanclass="sc">-</span><spanclass="sc">-</span></span>
<spanid="cb1-13"><ahref="#cb1-13"tabindex="-1"></a> S or I <spanclass="sc"><</span><spanclass="cn">NA</span><spanclass="sc">></span> X X <spanclass="sc">-</span><spanclass="sc">-</span></span>
<spanid="cb1-14"><ahref="#cb1-14"tabindex="-1"></a> R <spanclass="sc"><</span><spanclass="cn">NA</span><spanclass="sc">></span><spanclass="sc">-</span><spanclass="sc">-</span><spanclass="sc">-</span><spanclass="sc">-</span></span>
<divclass="sourceCode"><preclass="sourceCode r"><code><spanclass="r-in"><span><spanclass="co"># example_isolates is a data set available in the AMR package.</span></span></span>
<spanclass="r-in"><span><spanclass="co"># run ?example_isolates for more info.</span></span></span>
<spanclass="r-in"><span></span></span>
<spanclass="r-in"><span><spanclass="co"># base R ------------------------------------------------------------</span></span></span>
<spanclass="r-in"><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></span></span>
<spanclass="r-in"><span> R <spanclass="op">=</span><spanclass="fu">count_R</span><spanclass="op">(</span><spanclass="va">CIP</span><spanclass="op">)</span>,</span></span>
<spanclass="r-in"><span> I <spanclass="op">=</span><spanclass="fu">count_I</span><spanclass="op">(</span><spanclass="va">CIP</span><spanclass="op">)</span>,</span></span>
<spanclass="r-in"><span> S <spanclass="op">=</span><spanclass="fu">count_S</span><spanclass="op">(</span><spanclass="va">CIP</span><spanclass="op">)</span>,</span></span>
<spanclass="r-in"><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></span></span>
<spanclass="r-in"><span> n2 <spanclass="op">=</span><spanclass="fu">n_sir</span><spanclass="op">(</span><spanclass="va">CIP</span><spanclass="op">)</span>, <spanclass="co"># same - analogous to n_distinct</span></span></span>
<spanclass="r-in"><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></span></span>
<spanclass="r-in"><span><spanclass="op">)</span><spanclass="co"># NOT the number of tested isolates!</span></span></span>
<p><code>AMR</code> (for R). Free and open-source, licenced under the <atarget="_blank"href="https://github.com/msberends/AMR/blob/main/LICENSE"class="external-link">GNU General Public License version 2.0 (GPL-2)</a>.<br>Developed at the <atarget="_blank"href="https://www.rug.nl"class="external-link">University of Groningen</a> and <atarget="_blank"href="https://www.umcg.nl"class="external-link">University Medical Center Groningen</a> in The Netherlands.</p>