1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 22:06:11 +01:00

website update

This commit is contained in:
dr. M.S. (Matthijs) Berends 2018-12-31 14:30:06 +01:00
parent 154fec27dd
commit 4255707cb7
28 changed files with 64036 additions and 613 deletions

View File

@ -190,8 +190,8 @@
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">patients &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/unlist">unlist</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/lapply">lapply</a></span>(LETTERS, paste0, <span class="dv">1</span>:<span class="dv">10</span>))</code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">patients &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/unlist">unlist</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/lapply">lapply</a></span>(LETTERS, paste0, <span class="dv">1</span>:<span class="dv">10</span>))</code></pre></div>
<p>The <code>LETTERS</code> object is available in R - its a vector with 26 characters: <code>A</code> to <code>Z</code>. The <code>patients</code> object we just created is now a vector of length 260, with values (patient IDs) varying from <code>A1</code> to <code>Z10</code>. Now we we also set the gender of our patients, by putting the ID and the gender in a table:</p> <p>The <code>LETTERS</code> object is available in R - its a vector with 26 characters: <code>A</code> to <code>Z</code>. The <code>patients</code> object we just created is now a vector of length 260, with values (patient IDs) varying from <code>A1</code> to <code>Z10</code>. Now we we also set the gender of our patients, by putting the ID and the gender in a table:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">patients_table &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/data.frame">data.frame</a></span>(<span class="dt">patient_id =</span> patients, <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">patients_table &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/data.frame">data.frame</a></span>(<span class="dt">patient_id =</span> patients,
<span class="dt">gender =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/strrep">strrep</a></span>(<span class="st">"M"</span>, <span class="dv">135</span>), <span class="dt">gender =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/rep">rep</a></span>(<span class="st">"M"</span>, <span class="dv">135</span>),
<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/strrep">strrep</a></span>(<span class="st">"F"</span>, <span class="dv">125</span>)))</code></pre></div> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/rep">rep</a></span>(<span class="st">"F"</span>, <span class="dv">125</span>)))</code></pre></div>
<p>The first 135 patient IDs are now male, the other 125 are female.</p> <p>The first 135 patient IDs are now male, the other 125 are female.</p>
</div> </div>
<div id="dates" class="section level4"> <div id="dates" class="section level4">
@ -246,70 +246,70 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
</tr></thead> </tr></thead>
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">2011-11-05</td> <td align="center">2015-12-16</td>
<td align="center">F8</td> <td align="center">C5</td>
<td align="center">Hospital A</td> <td align="center">Hospital A</td>
<td align="center">Streptococcus pneumoniae</td> <td align="center">Staphylococcus aureus</td>
<td align="center">S</td>
<td align="center">I</td> <td align="center">I</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td> <td align="center">S</td>
<td align="center">M</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2013-06-01</td> <td align="center">2016-11-26</td>
<td align="center">L1</td> <td align="center">Y1</td>
<td align="center">Hospital C</td> <td align="center">Hospital D</td>
<td align="center">Streptococcus pneumoniae</td> <td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">I</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td> <td align="center">F</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">2014-05-29</td> <td align="center">2016-08-27</td>
<td align="center">X5</td> <td align="center">E3</td>
<td align="center">Hospital D</td> <td align="center">Hospital B</td>
<td align="center">Escherichia coli</td> <td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2014-01-30</td>
<td align="center">V9</td>
<td align="center">Hospital A</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td> <td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2010-05-14</td>
<td align="center">S10</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2013-06-29</td> <td align="center">2015-12-21</td>
<td align="center">K6</td> <td align="center">N8</td>
<td align="center">Hospital B</td> <td align="center">Hospital B</td>
<td align="center">Escherichia coli</td> <td align="center">Escherichia coli</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
</tr>
<tr class="odd">
<td align="center">2015-02-02</td>
<td align="center">W2</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">F</td>
<td align="center">S</td>
<td align="center">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
</tr>
<tr class="even">
<td align="center">2011-10-28</td>
<td align="center">T5</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -323,14 +323,14 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data %&gt;%<span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender) <span class="co"># this would be the same: freq(data$gender)</span></code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data %&gt;%<span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender) <span class="co"># this would be the same: freq(data$gender)</span></code></pre></div>
<pre><code># Frequency table of `gender` <pre><code># Frequency table of `gender`
# Class: factor (numeric) # Class: factor (numeric)
# Levels: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM # Levels: F, M
# Length: 5,000 (of which NA: 0 = 0.00%) # Length: 5,000 (of which NA: 0 = 0.00%)
# Unique: 2 # Unique: 2
# #
# Item Count Percent Cum. Count Cum. Percent # Item Count Percent Cum. Count Cum. Percent
# --- ---------------------------------------------------------------------------------------------------------------------------------------- ------ -------- ----------- ------------- # --- ----- ------ -------- ----------- -------------
# 1 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 2,536 50.7% 2,536 50.7% # 1 M 2,568 51.4% 2,568 51.4%
# 2 MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 2,464 49.3% 5,000 100.0%</code></pre> # 2 F 2,432 48.6% 5,000 100.0%</code></pre>
<p>So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values <code>M</code> and <code>F</code>. From a researcher perspective: there are slightly more men. Nothing we didnt already know.</p> <p>So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values <code>M</code> and <code>F</code>. From a researcher perspective: there are slightly more men. Nothing we didnt already know.</p>
<p>The data is already quite clean, but we still need to transform some variables. The <code>bacteria</code> column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The <code>mutate</code> function of the dplyr package makes this really easy:</p> <p>The data is already quite clean, but we still need to transform some variables. The <code>bacteria</code> column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The <code>mutate</code> function of the dplyr package makes this really easy:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span>data %&gt;% <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span>data %&gt;%
@ -349,7 +349,7 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<span class="co"># Staphylococcus (no changes)</span> <span class="co"># Staphylococcus (no changes)</span>
<span class="co"># Enterococcus (no changes)</span> <span class="co"># Enterococcus (no changes)</span>
<span class="co"># Streptococcus groups A, B, C, G (no changes)</span> <span class="co"># Streptococcus groups A, B, C, G (no changes)</span>
<span class="co"># Streptococcus pneumoniae (366 changes)</span> <span class="co"># Streptococcus pneumoniae (358 changes)</span>
<span class="co"># Viridans group streptococci (no changes)</span> <span class="co"># Viridans group streptococci (no changes)</span>
<span class="co"># Haemophilus influenzae (no changes)</span> <span class="co"># Haemophilus influenzae (no changes)</span>
<span class="co"># Moraxella catarrhalis (no changes)</span> <span class="co"># Moraxella catarrhalis (no changes)</span>
@ -361,10 +361,10 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<span class="co"># Kingella kingae (no changes)</span> <span class="co"># Kingella kingae (no changes)</span>
<span class="co"># </span> <span class="co"># </span>
<span class="co"># EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span> <span class="co"># EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span>
<span class="co"># Table 1: Intrinsic resistance in Enterobacteriaceae (332 changes)</span> <span class="co"># Table 1: Intrinsic resistance in Enterobacteriaceae (341 changes)</span>
<span class="co"># Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span> <span class="co"># Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span>
<span class="co"># Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span> <span class="co"># Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span>
<span class="co"># Table 4: Intrinsic resistance in Gram-positive bacteria (699 changes)</span> <span class="co"># Table 4: Intrinsic resistance in Gram-positive bacteria (704 changes)</span>
<span class="co"># Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span> <span class="co"># Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span>
<span class="co"># Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span> <span class="co"># Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span>
<span class="co"># Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span> <span class="co"># Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span>
@ -373,14 +373,14 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<span class="co"># Table 13: Interpretive rules for quinolones (no changes)</span> <span class="co"># Table 13: Interpretive rules for quinolones (no changes)</span>
<span class="co"># </span> <span class="co"># </span>
<span class="co"># Other rules</span> <span class="co"># Other rules</span>
<span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (351 changes)</span> <span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (366 changes)</span>
<span class="co"># Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span> <span class="co"># Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span>
<span class="co"># Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span> <span class="co"># Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span>
<span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (242 changes)</span> <span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (217 changes)</span>
<span class="co"># Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span> <span class="co"># Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span>
<span class="co"># Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span> <span class="co"># Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span>
<span class="co"># </span> <span class="co"># </span>
<span class="co"># =&gt; EUCAST rules affected 4,575 out of 5,000 rows -&gt; changed 1,990 test results.</span></code></pre></div> <span class="co"># =&gt; EUCAST rules affected 4,613 out of 5,000 rows -&gt; changed 1,986 test results.</span></code></pre></div>
</div> </div>
<div id="adding-new-variables" class="section level2"> <div id="adding-new-variables" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">
@ -404,8 +404,8 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span> <span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<span class="co"># NOTE: Using column `date` as input for `col_date`.</span> <span class="co"># NOTE: Using column `date` as input for `col_date`.</span>
<span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span> <span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span>
<span class="co"># =&gt; Found 2,928 first isolates (58.6% of total)</span></code></pre></div> <span class="co"># =&gt; Found 2,941 first isolates (58.8% of total)</span></code></pre></div>
<p>So only 58.6% is suitable for resistance analysis! We can now filter on is with the <code><a href="http://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p> <p>So only 58.8% is suitable for resistance analysis! We can now filter on is with the <code><a href="http://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span>
<span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first ==<span class="st"> </span><span class="ot">TRUE</span>)</code></pre></div> <span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first ==<span class="st"> </span><span class="ot">TRUE</span>)</code></pre></div>
<p>For future use, the above two syntaxes can be shortened with the <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> function:</p> <p>For future use, the above two syntaxes can be shortened with the <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> function:</p>
@ -431,41 +431,30 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">1</td> <td align="center">1</td>
<td align="center">2010-04-08</td> <td align="center">2010-08-17</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2</td> <td align="center">2</td>
<td align="center">2010-07-04</td> <td align="center">2011-07-17</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">3</td> <td align="center">3</td>
<td align="center">2010-07-25</td> <td align="center">2012-02-06</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2011-08-12</td>
<td align="center">W2</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
@ -473,10 +462,21 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2012-06-16</td>
<td align="center">D4</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd"> <tr class="odd">
<td align="center">5</td> <td align="center">5</td>
<td align="center">2012-03-16</td> <td align="center">2012-09-13</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
@ -486,52 +486,52 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">6</td> <td align="center">6</td>
<td align="center">2012-08-15</td> <td align="center">2013-06-02</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">7</td> <td align="center">7</td>
<td align="center">2013-01-15</td> <td align="center">2014-12-11</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">8</td> <td align="center">8</td>
<td align="center">2013-06-15</td> <td align="center">2015-03-23</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">9</td> <td align="center">9</td>
<td align="center">2013-09-18</td> <td align="center">2015-04-14</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">10</td> <td align="center">10</td>
<td align="center">2014-01-13</td> <td align="center">2015-05-19</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
@ -554,7 +554,7 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span> <span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span>
<span class="co"># NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span> <span class="co"># NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span>
<span class="co"># [Criterion] Inclusion based on key antibiotics, ignoring I.</span> <span class="co"># [Criterion] Inclusion based on key antibiotics, ignoring I.</span>
<span class="co"># =&gt; Found 4,412 first weighted isolates (88.2% of total)</span></code></pre></div> <span class="co"># =&gt; Found 4,415 first weighted isolates (88.3% of total)</span></code></pre></div>
<table class="table"> <table class="table">
<thead><tr class="header"> <thead><tr class="header">
<th align="center">isolate</th> <th align="center">isolate</th>
@ -571,116 +571,116 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">1</td> <td align="center">1</td>
<td align="center">2010-04-08</td> <td align="center">2010-08-17</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2</td> <td align="center">2</td>
<td align="center">2010-07-04</td> <td align="center">2011-07-17</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">3</td> <td align="center">3</td>
<td align="center">2010-07-25</td> <td align="center">2012-02-06</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">S</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">4</td> <td align="center">4</td>
<td align="center">2011-08-12</td> <td align="center">2012-06-16</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">5</td> <td align="center">5</td>
<td align="center">2012-03-16</td> <td align="center">2012-09-13</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
<td align="center">FALSE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">6</td> <td align="center">6</td>
<td align="center">2012-08-15</td> <td align="center">2013-06-02</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">7</td> <td align="center">7</td>
<td align="center">2013-01-15</td> <td align="center">2014-12-11</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">8</td> <td align="center">8</td>
<td align="center">2013-06-15</td> <td align="center">2015-03-23</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
<td align="center">TRUE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">9</td> <td align="center">9</td>
<td align="center">2013-09-18</td> <td align="center">2015-04-14</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">FALSE</td>
<td align="center">TRUE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">10</td> <td align="center">10</td>
<td align="center">2014-01-13</td> <td align="center">2015-05-19</td>
<td align="center">W2</td> <td align="center">D4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
@ -691,11 +691,11 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p>Instead of 4, now 9 isolates are flagged. In total, 88.2% of all isolates are marked first weighted - 29.7% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p> <p>Instead of 4, now 7 isolates are flagged. In total, 88.3% of all isolates are marked first weighted - 29.5% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
<p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, theres a shortcut for this new algorithm too:</p> <p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, theres a shortcut for this new algorithm too:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span>
<span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</code></pre></div> <span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</code></pre></div>
<p>So we end up with 4,412 isolates for analysis.</p> <p>So we end up with 4,415 isolates for analysis.</p>
<p>We can remove unneeded columns:</p> <p>We can remove unneeded columns:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data_1st %&gt;%<span class="st"> </span> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data_1st %&gt;%<span class="st"> </span>
<span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/select.html">select</a></span>(-first, -keyab)</code></pre></div> <span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/select.html">select</a></span>(-first, -keyab)</code></pre></div>
@ -703,7 +703,6 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">head</a></span>(data_1st)</code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">head</a></span>(data_1st)</code></pre></div>
<table class="table"> <table class="table">
<thead><tr class="header"> <thead><tr class="header">
<th></th>
<th align="center">date</th> <th align="center">date</th>
<th align="center">patient_id</th> <th align="center">patient_id</th>
<th align="center">hospital</th> <th align="center">hospital</th>
@ -719,91 +718,85 @@ ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https
</tr></thead> </tr></thead>
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td>1</td> <td align="center">2015-12-16</td>
<td align="center">2011-11-05</td> <td align="center">C5</td>
<td align="center">F8</td>
<td align="center">Hospital A</td> <td align="center">Hospital A</td>
<td align="center">B_STRPTC_PNE</td> <td align="center">B_STPHY_AUR</td>
<td align="center">I</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">M</td>
<td align="center">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
<td align="center">Gram positive</td> <td align="center">Gram positive</td>
<td align="center">Streptococcaceae</td> <td align="center">Staphylococcaceae</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td>2</td> <td align="center">2016-11-26</td>
<td align="center">2013-06-01</td> <td align="center">Y1</td>
<td align="center">L1</td> <td align="center">Hospital D</td>
<td align="center">Hospital C</td>
<td align="center">B_STRPTC_PNE</td> <td align="center">B_STRPTC_PNE</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td> <td align="center">R</td>
<td align="center">F</td>
<td align="center">Gram positive</td> <td align="center">Gram positive</td>
<td align="center">Streptococcaceae</td> <td align="center">Streptococcaceae</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td>4</td> <td align="center">2016-08-27</td>
<td align="center">2013-06-29</td> <td align="center">E3</td>
<td align="center">K6</td> <td align="center">Hospital B</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2014-01-30</td>
<td align="center">V9</td>
<td align="center">Hospital A</td>
<td align="center">B_STPHY_AUR</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">Gram positive</td>
<td align="center">Staphylococcaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">2010-05-14</td>
<td align="center">S10</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AUR</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">Gram positive</td>
<td align="center">Staphylococcaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2015-12-21</td>
<td align="center">N8</td>
<td align="center">Hospital B</td> <td align="center">Hospital B</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
<td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>6</td>
<td align="center">2011-10-28</td>
<td align="center">T5</td>
<td align="center">Hospital D</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td> <td align="center">F</td>
<td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>7</td>
<td align="center">2017-03-11</td>
<td align="center">D5</td>
<td align="center">Hospital D</td>
<td align="center">B_KLBSL_PNE</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td>
<td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>8</td>
<td align="center">2013-04-06</td>
<td align="center">F6</td>
<td align="center">Hospital A</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
<td align="center">Gram negative</td> <td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td> <td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>

View File

@ -210,14 +210,7 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='fu'>ab_atc</span>(<span class='st'>"amcl"</span>) <span class='co'># J01CR02</span></div><div class='output co'>#&gt; [1] "J01CR02"</div><div class='input'><span class='fu'>ab_name</span>(<span class='st'>"amcl"</span>) <span class='co'># Amoxicillin and beta-lactamase inhibitor</span></div><div class='output co'>#&gt; [1] "Amoxicillin and beta-lactamase inhibitor"</div><div class='input'><span class='fu'>ab_name</span>(<span class='st'>"amcl"</span>, <span class='st'>"nl"</span>) <span class='co'># Amoxicilline met enzymremmer</span></div><div class='output co'>#&gt; [1] "Amoxicilline met enzymremmer"</div><div class='input'><span class='fu'>ab_trivial_nl</span>(<span class='st'>"amcl"</span>) <span class='co'># Amoxicilline/clavulaanzuur</span></div><div class='output co'>#&gt; [1] "Amoxicilline/clavulaanzuur"</div><div class='input'><span class='fu'>ab_certe</span>(<span class='st'>"amcl"</span>) <span class='co'># amcl</span></div><div class='output co'>#&gt; [1] "amcl"</div><div class='input'><span class='fu'>ab_umcg</span>(<span class='st'>"amcl"</span>) <span class='co'># AMCL</span></div><div class='output co'>#&gt; [1] "AMCL"</div></pre>
<span class='fu'>ab_atc</span>(<span class='st'>"amcl"</span>) <span class='co'># J01CR02</span>
<span class='fu'>ab_name</span>(<span class='st'>"amcl"</span>) <span class='co'># Amoxicillin and beta-lactamase inhibitor</span>
<span class='fu'>ab_name</span>(<span class='st'>"amcl"</span>, <span class='st'>"nl"</span>) <span class='co'># Amoxicilline met enzymremmer</span>
<span class='fu'>ab_trivial_nl</span>(<span class='st'>"amcl"</span>) <span class='co'># Amoxicilline/clavulaanzuur</span>
<span class='fu'>ab_certe</span>(<span class='st'>"amcl"</span>) <span class='co'># amcl</span>
<span class='fu'>ab_umcg</span>(<span class='st'>"amcl"</span>) <span class='co'># AMCL</span>
<span class='co'># }</span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -201,36 +201,28 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='fu'>abname</span>(<span class='st'>"AMCL"</span>)</div><div class='output co'>#&gt; [1] "Amoxicillin and beta-lactamase inhibitor"</div><div class='input'><span class='co'># "Amoxicillin and beta-lactamase inhibitor"</span>
<span class='fu'>abname</span>(<span class='st'>"AMCL"</span>)
<span class='co'># "Amoxicillin and beta-lactamase inhibitor"</span>
<span class='co'># It is quite flexible at default (having `from = "guess"`)</span> <span class='co'># It is quite flexible at default (having `from = "guess"`)</span>
<span class='fu'>abname</span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"amox"</span>, <span class='st'>"J01CA04"</span>, <span class='st'>"Trimox"</span>, <span class='st'>"dispermox"</span>, <span class='st'>"Amoxil"</span>)) <span class='fu'>abname</span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"amox"</span>, <span class='st'>"J01CA04"</span>, <span class='st'>"Trimox"</span>, <span class='st'>"dispermox"</span>, <span class='st'>"Amoxil"</span>))</div><div class='output co'>#&gt; [1] "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin"</div><div class='input'><span class='co'># "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin"</span>
<span class='co'># "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin"</span>
<span class='co'># Multiple antibiotics can be combined with "+".</span> <span class='co'># Multiple antibiotics can be combined with "+".</span>
<span class='co'># The second antibiotic will be set to lower case when `tolower` was not set:</span> <span class='co'># The second antibiotic will be set to lower case when `tolower` was not set:</span>
<span class='fu'>abname</span>(<span class='st'>"AMCL+GENT"</span>, <span class='kw'>textbetween</span> <span class='kw'>=</span> <span class='st'>"/"</span>) <span class='fu'>abname</span>(<span class='st'>"AMCL+GENT"</span>, <span class='kw'>textbetween</span> <span class='kw'>=</span> <span class='st'>"/"</span>)</div><div class='output co'>#&gt; [1] "Amoxicillin and beta-lactamase inhibitor/gentamicin"</div><div class='input'><span class='co'># "amoxicillin and enzyme inhibitor/gentamicin"</span>
<span class='co'># "amoxicillin and enzyme inhibitor/gentamicin"</span>
<span class='fu'>abname</span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"AMCL"</span>, <span class='st'>"GENT"</span>)) <span class='fu'>abname</span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"AMCL"</span>, <span class='st'>"GENT"</span>))</div><div class='output co'>#&gt; [1] "Amoxicillin and beta-lactamase inhibitor"
<span class='co'># "Amoxicillin and beta-lactamase inhibitor" "Gentamicin"</span> #&gt; [2] "Gentamicin" </div><div class='input'><span class='co'># "Amoxicillin and beta-lactamase inhibitor" "Gentamicin"</span>
<span class='fu'>abname</span>(<span class='st'>"AMCL"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"trivial_nl"</span>) <span class='fu'>abname</span>(<span class='st'>"AMCL"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"trivial_nl"</span>)</div><div class='output co'>#&gt; [1] "Amoxicilline/clavulaanzuur"</div><div class='input'><span class='co'># "Amoxicilline/clavulaanzuur"</span>
<span class='co'># "Amoxicilline/clavulaanzuur"</span>
<span class='fu'>abname</span>(<span class='st'>"AMCL"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"atc"</span>) <span class='fu'>abname</span>(<span class='st'>"AMCL"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"atc"</span>)</div><div class='output co'>#&gt; [1] "J01CR02"</div><div class='input'><span class='co'># "J01CR02"</span>
<span class='co'># "J01CR02"</span>
<span class='co'># specific codes for University Medical Center Groningen (UMCG):</span> <span class='co'># specific codes for University Medical Center Groningen (UMCG):</span>
<span class='fu'>abname</span>(<span class='st'>"J01CR02"</span>, <span class='kw'>from</span> <span class='kw'>=</span> <span class='st'>"atc"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"umcg"</span>) <span class='fu'>abname</span>(<span class='st'>"J01CR02"</span>, <span class='kw'>from</span> <span class='kw'>=</span> <span class='st'>"atc"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"umcg"</span>)</div><div class='output co'>#&gt; [1] "AMCL"</div><div class='input'><span class='co'># "AMCL"</span>
<span class='co'># "AMCL"</span>
<span class='co'># specific codes for Certe:</span> <span class='co'># specific codes for Certe:</span>
<span class='fu'>abname</span>(<span class='st'>"J01CR02"</span>, <span class='kw'>from</span> <span class='kw'>=</span> <span class='st'>"atc"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"certe"</span>) <span class='fu'>abname</span>(<span class='st'>"J01CR02"</span>, <span class='kw'>from</span> <span class='kw'>=</span> <span class='st'>"atc"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"certe"</span>)</div><div class='output co'>#&gt; [1] "amcl"</div><div class='input'># "amcl"
<span class='co'># "amcl"</span> </div></pre>
<span class='co'># }</span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -205,39 +205,43 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='no'>ages</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>3</span>, <span class='fl'>8</span>, <span class='fl'>16</span>, <span class='fl'>54</span>, <span class='fl'>31</span>, <span class='fl'>76</span>, <span class='fl'>101</span>, <span class='fl'>43</span>, <span class='fl'>21</span>)
<span class='no'>ages</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>3</span>, <span class='fl'>8</span>, <span class='fl'>16</span>, <span class='fl'>54</span>, <span class='fl'>31</span>, <span class='fl'>76</span>, <span class='fl'>101</span>, <span class='fl'>43</span>, <span class='fl'>21</span>)
<span class='co'># split into 0-49 and 50+</span> <span class='co'># split into 0-49 and 50+</span>
<span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fl'>50</span>) <span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fl'>50</span>)</div><div class='output co'>#&gt; [1] 0-49 0-49 0-49 50+ 0-49 50+ 50+ 0-49 0-49
#&gt; Levels: 0-49 &lt; 50+</div><div class='input'>
<span class='co'># split into 0-19, 20-49 and 50+</span> <span class='co'># split into 0-19, 20-49 and 50+</span>
<span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>20</span>, <span class='fl'>50</span>)) <span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>20</span>, <span class='fl'>50</span>))</div><div class='output co'>#&gt; [1] 0-19 0-19 0-19 50+ 20-49 50+ 50+ 20-49 20-49
#&gt; Levels: 0-19 &lt; 20-49 &lt; 50+</div><div class='input'>
<span class='co'># split into groups of ten years</span> <span class='co'># split into groups of ten years</span>
<span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fl'>1</span>:<span class='fl'>10</span> * <span class='fl'>10</span>) <span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fl'>1</span>:<span class='fl'>10</span> * <span class='fl'>10</span>)</div><div class='output co'>#&gt; [1] 0-9 0-9 10-19 50-59 30-39 70-79 100+ 40-49 20-29
<span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='kw'>split_at</span> <span class='kw'>=</span> <span class='st'>"tens"</span>) #&gt; 11 Levels: 0-9 &lt; 10-19 &lt; 20-29 &lt; 30-39 &lt; 40-49 &lt; 50-59 &lt; 60-69 &lt; ... &lt; 100+</div><div class='input'><span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='kw'>split_at</span> <span class='kw'>=</span> <span class='st'>"tens"</span>)</div><div class='output co'>#&gt; [1] 0-9 0-9 10-19 50-59 30-39 70-79 100+ 40-49 20-29
#&gt; 11 Levels: 0-9 &lt; 10-19 &lt; 20-29 &lt; 30-39 &lt; 40-49 &lt; 50-59 &lt; 60-69 &lt; ... &lt; 100+</div><div class='input'>
<span class='co'># split into groups of five years</span> <span class='co'># split into groups of five years</span>
<span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fl'>1</span>:<span class='fl'>20</span> * <span class='fl'>5</span>) <span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fl'>1</span>:<span class='fl'>20</span> * <span class='fl'>5</span>)</div><div class='output co'>#&gt; [1] 0-4 5-9 15-19 50-54 30-34 75-79 100+ 40-44 20-24
<span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='kw'>split_at</span> <span class='kw'>=</span> <span class='st'>"fives"</span>) #&gt; 21 Levels: 0-4 &lt; 5-9 &lt; 10-14 &lt; 15-19 &lt; 20-24 &lt; 25-29 &lt; 30-34 &lt; ... &lt; 100+</div><div class='input'><span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='kw'>split_at</span> <span class='kw'>=</span> <span class='st'>"fives"</span>)</div><div class='output co'>#&gt; [1] 0-4 5-9 15-19 50-54 30-34 75-79 100+ 40-44 20-24
#&gt; 21 Levels: 0-4 &lt; 5-9 &lt; 10-14 &lt; 15-19 &lt; 20-24 &lt; 25-29 &lt; 30-34 &lt; ... &lt; 100+</div><div class='input'>
<span class='co'># split specifically for children</span> <span class='co'># split specifically for children</span>
<span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='st'>"children"</span>) <span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='st'>"children"</span>)</div><div class='output co'>#&gt; [1] 2-3 6-12 13-17 18+ 18+ 18+ 18+ 18+ 18+
<span class='co'># same:</span> #&gt; Levels: 0 &lt; 1 &lt; 2-3 &lt; 4-5 &lt; 6-12 &lt; 13-17 &lt; 18+</div><div class='input'><span class='co'># same:</span>
<span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>1</span>, <span class='fl'>2</span>, <span class='fl'>4</span>, <span class='fl'>6</span>, <span class='fl'>13</span>, <span class='fl'>17</span>)) <span class='fu'>age_groups</span>(<span class='no'>ages</span>, <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>1</span>, <span class='fl'>2</span>, <span class='fl'>4</span>, <span class='fl'>6</span>, <span class='fl'>13</span>, <span class='fl'>17</span>))</div><div class='output co'>#&gt; [1] 2-3 6-12 13-16 17+ 17+ 17+ 17+ 17+ 17+
#&gt; Levels: 0 &lt; 1 &lt; 2-3 &lt; 4-5 &lt; 6-12 &lt; 13-16 &lt; 17+</div><div class='input'>
<span class='co'># resistance of ciprofloxacine per age group</span> <span class='co'># resistance of ciprofloxacine per age group</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>) <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)</div><div class='output co'>#&gt; <span class='message'></span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> #&gt; <span class='message'>Attaching package: dplyr</span></div><div class='output co'>#&gt; <span class='message'>The following object is masked from package:testthat:</span>
#&gt; <span class='message'></span>
#&gt; <span class='message'> matches</span></div><div class='output co'>#&gt; <span class='message'>The following objects are masked from package:stats:</span>
#&gt; <span class='message'></span>
#&gt; <span class='message'> filter, lag</span></div><div class='output co'>#&gt; <span class='message'>The following objects are masked from package:base:</span>
#&gt; <span class='message'></span>
#&gt; <span class='message'> intersect, setdiff, setequal, union</span></div><div class='input'><span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>first_isolate</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>.</span>)) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>first_isolate</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>.</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>, <span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>,
<span class='no'>mo</span> <span class='kw'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='kw'>%&gt;%</span> <span class='no'>mo</span> <span class='kw'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>age_group</span> <span class='kw'>=</span> <span class='fu'>age_groups</span>(<span class='no'>age</span>)) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>age_group</span> <span class='kw'>=</span> <span class='fu'>age_groups</span>(<span class='no'>age</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>age_group</span>, <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>age_group</span>,
<span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='ggplot_rsi.html'>ggplot_rsi</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"age_group"</span>) <span class='fu'><a href='ggplot_rsi.html'>ggplot_rsi</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"age_group"</span>)</div><div class='output co'>#&gt; <span class='message'><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>mo</span><span style='color: #0000BB;'>` as input for `col_mo`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>date</span><span style='color: #0000BB;'>` as input for `col_date`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>patient_id</span><span style='color: #0000BB;'>` as input for `col_patient_id`.</span><span></span></div><div class='output co'>#&gt; <span class='message'>=&gt; Found </span><span style='font-weight: bold;'>1,317 first isolates</span><span> (65.9% of total)</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Removed 3 rows containing missing values (geom_bar).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Removed 3 rows containing missing values (geom_text).</span></div><div class='img'><img src='age_groups-1.png' alt='' width='700' height='433' /></div></span></pre>
<span class='co'># }</span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -198,23 +198,20 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># These examples all return "J01FA01", the ATC code of Erythromycin:</span>
<span class='co'># These examples all return "J01FA01", the ATC code of Erythromycin:</span> <span class='fu'>as.atc</span>(<span class='st'>"J01FA01"</span>)</div><div class='output co'>#&gt; Class 'atc'
<span class='fu'>as.atc</span>(<span class='st'>"J01FA01"</span>) #&gt; [1] J01FA01</div><div class='input'><span class='fu'>as.atc</span>(<span class='st'>"Erythromycin"</span>)</div><div class='output co'>#&gt; Class 'atc'
<span class='fu'>as.atc</span>(<span class='st'>"Erythromycin"</span>) #&gt; [1] J01FA01</div><div class='input'><span class='fu'>as.atc</span>(<span class='st'>"eryt"</span>)</div><div class='output co'>#&gt; Class 'atc'
<span class='fu'>as.atc</span>(<span class='st'>"eryt"</span>) #&gt; [1] J01FA01</div><div class='input'><span class='fu'>as.atc</span>(<span class='st'>" eryt 123"</span>)</div><div class='output co'>#&gt; Class 'atc'
<span class='fu'>as.atc</span>(<span class='st'>" eryt 123"</span>) #&gt; [1] J01FA01</div><div class='input'><span class='fu'>as.atc</span>(<span class='st'>"ERYT"</span>)</div><div class='output co'>#&gt; Class 'atc'
<span class='fu'>as.atc</span>(<span class='st'>"ERYT"</span>) #&gt; [1] J01FA01</div><div class='input'><span class='fu'>as.atc</span>(<span class='st'>"ERY"</span>)</div><div class='output co'>#&gt; Class 'atc'
<span class='fu'>as.atc</span>(<span class='st'>"ERY"</span>) #&gt; [1] J01FA01</div><div class='input'><span class='fu'>as.atc</span>(<span class='st'>"Erythrocin"</span>) <span class='co'># Trade name</span></div><div class='output co'>#&gt; Class 'atc'
<span class='fu'>as.atc</span>(<span class='st'>"Erythrocin"</span>) <span class='co'># Trade name</span> #&gt; [1] J01FA01</div><div class='input'><span class='fu'>as.atc</span>(<span class='st'>"Eryzole"</span>) <span class='co'># Trade name</span></div><div class='output co'>#&gt; Class 'atc'
<span class='fu'>as.atc</span>(<span class='st'>"Eryzole"</span>) <span class='co'># Trade name</span> #&gt; [1] J01FA01</div><div class='input'><span class='fu'>as.atc</span>(<span class='st'>"Pediamycin"</span>) <span class='co'># Trade name</span></div><div class='output co'>#&gt; Class 'atc'
<span class='fu'>as.atc</span>(<span class='st'>"Pediamycin"</span>) <span class='co'># Trade name</span> #&gt; [1] J01FA01</div><div class='input'>
<span class='co'># Use ab_* functions to get a specific property based on an ATC code</span> <span class='co'># Use ab_* functions to get a specific property based on an ATC code</span>
<span class='no'>Cipro</span> <span class='kw'>&lt;-</span> <span class='fu'>as.atc</span>(<span class='st'>"cipro"</span>) <span class='co'># returns `J01MA02`</span> <span class='no'>Cipro</span> <span class='kw'>&lt;-</span> <span class='fu'>as.atc</span>(<span class='st'>"cipro"</span>) <span class='co'># returns `J01MA02`</span>
<span class='fu'><a href='ab_property.html'>ab_official</a></span>(<span class='no'>Cipro</span>) <span class='co'># returns "Ciprofloxacin"</span> <span class='fu'><a href='ab_property.html'>ab_official</a></span>(<span class='no'>Cipro</span>) <span class='co'># returns "Ciprofloxacin"</span></div><div class='output co'>#&gt; [1] "Ciprofloxacin"</div><div class='input'><span class='fu'><a href='ab_property.html'>ab_umcg</a></span>(<span class='no'>Cipro</span>) <span class='co'># returns "CIPR", the code used in the UMCG</span></div><div class='output co'>#&gt; [1] "CIPR"</div></pre>
<span class='fu'><a href='ab_property.html'>ab_umcg</a></span>(<span class='no'>Cipro</span>) <span class='co'># returns "CIPR", the code used in the UMCG</span>
<span class='co'># }</span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -194,17 +194,25 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='no'>mic_data</span> <span class='kw'>&lt;-</span> <span class='fu'>as.mic</span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"&gt;=32"</span>, <span class='st'>"1.0"</span>, <span class='st'>"1"</span>, <span class='st'>"1.00"</span>, <span class='fl'>8</span>, <span class='st'>"&lt;=0.128"</span>, <span class='st'>"8"</span>, <span class='st'>"16"</span>, <span class='st'>"16"</span>))
<span class='no'>mic_data</span> <span class='kw'>&lt;-</span> <span class='fu'>as.mic</span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"&gt;=32"</span>, <span class='st'>"1.0"</span>, <span class='st'>"1"</span>, <span class='st'>"1.00"</span>, <span class='fl'>8</span>, <span class='st'>"&lt;=0.128"</span>, <span class='st'>"8"</span>, <span class='st'>"16"</span>, <span class='st'>"16"</span>)) <span class='fu'>is.mic</span>(<span class='no'>mic_data</span>)</div><div class='output co'>#&gt; [1] TRUE</div><div class='input'>
<span class='fu'>is.mic</span>(<span class='no'>mic_data</span>)
<span class='co'># this can also coerce combined MIC/RSI values:</span> <span class='co'># this can also coerce combined MIC/RSI values:</span>
<span class='fu'>as.mic</span>(<span class='st'>"&lt;=0.002; S"</span>) <span class='co'># will return &lt;=0.002</span> <span class='fu'>as.mic</span>(<span class='st'>"&lt;=0.002; S"</span>) <span class='co'># will return &lt;=0.002</span></div><div class='output co'>#&gt; Class 'mic'
#&gt; [1] &lt;=0.002</div><div class='input'>
<span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/plot'>plot</a></span>(<span class='no'>mic_data</span>) <span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/plot'>plot</a></span>(<span class='no'>mic_data</span>)</div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/barplot'>barplot</a></span>(<span class='no'>mic_data</span>)</div><div class='img'><img src='as.mic-1.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'><a href='freq.html'>freq</a></span>(<span class='no'>mic_data</span>)</div><div class='output co'>#&gt;
<span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/barplot'>barplot</a></span>(<span class='no'>mic_data</span>) #&gt;
<span class='fu'><a href='freq.html'>freq</a></span>(<span class='no'>mic_data</span>) #&gt; **Frequency table**
<span class='co'># }</span></pre> #&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:-------|-----:|-------:|----------:|------------:|
#&gt; |1 |1 | 3| 33.3%| 3| 33.3%|
#&gt; |2 |8 | 2| 22.2%| 5| 55.6%|
#&gt; |3 |16 | 2| 22.2%| 7| 77.8%|
#&gt; |4 |&lt;=0.128 | 1| 11.1%| 8| 88.9%|
#&gt; |5 |&gt;=32 | 1| 11.1%| 9| 100.0%|
#&gt;
#&gt; </div></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -263,41 +263,37 @@ The <code><a href='mo_property.html'>mo_property</a></code> functions (like <cod
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># These examples all return "B_STPHY_AUR", the ID of S. aureus:</span>
<span class='co'># These examples all return "B_STPHY_AUR", the ID of S. aureus:</span> <span class='fu'>as.mo</span>(<span class='st'>"stau"</span>)</div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"stau"</span>) #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"STAU"</span>)</div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"STAU"</span>) #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"staaur"</span>)</div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"staaur"</span>) #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"S. aureus"</span>)</div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"S. aureus"</span>) #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"S aureus"</span>)</div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"S aureus"</span>) #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"Staphylococcus aureus"</span>)</div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"Staphylococcus aureus"</span>) #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"Staphylococcus aureus (MRSA)"</span>)</div><div class='output co'>#&gt; <span class='warning'>Warning: <span style='color: #BB0000;'>UNCERTAIN - "Staphylococcus aureus (MRSA)" -&gt; </span><span style='color: #BB0000;font-style: italic;'>Staphylococcus aureus</span><span style='color: #BB0000;'> (B_STPHY_AUR)</span><span></span></div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"Staphylococcus aureus (MRSA)"</span>) #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"MRSA"</span>) <span class='co'># Methicillin Resistant S. aureus</span></div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"MRSA"</span>) <span class='co'># Methicillin Resistant S. aureus</span> #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"VISA"</span>) <span class='co'># Vancomycin Intermediate S. aureus</span></div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"VISA"</span>) <span class='co'># Vancomycin Intermediate S. aureus</span> #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"VRSA"</span>) <span class='co'># Vancomycin Resistant S. aureus</span></div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='st'>"VRSA"</span>) <span class='co'># Vancomycin Resistant S. aureus</span> #&gt; [1] B_STPHY_AUR</div><div class='input'><span class='fu'>as.mo</span>(<span class='fl'>369</span>) <span class='co'># Search on TSN (Taxonomic Serial Number), a unique identifier</span></div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>as.mo</span>(<span class='fl'>369</span>) <span class='co'># Search on TSN (Taxonomic Serial Number), a unique identifier</span> #&gt; [1] B_STPHY_AUR</div><div class='input'> <span class='co'># for the Integrated Taxonomic Information System (ITIS)</span>
<span class='co'># for the Integrated Taxonomic Information System (ITIS)</span>
<span class='fu'>as.mo</span>(<span class='st'>"Streptococcus group A"</span>)
<span class='fu'>as.mo</span>(<span class='st'>"GAS"</span>) <span class='co'># Group A Streptococci</span>
<span class='fu'>as.mo</span>(<span class='st'>"GBS"</span>) <span class='co'># Group B Streptococci</span>
<span class='fu'>as.mo</span>(<span class='st'>"Streptococcus group A"</span>)</div><div class='output co'>#&gt; Class 'mo'
#&gt; [1] B_STRPTC_GRA</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"GAS"</span>) <span class='co'># Group A Streptococci</span></div><div class='output co'>#&gt; Class 'mo'
#&gt; [1] B_STRPTC_GRA</div><div class='input'><span class='fu'>as.mo</span>(<span class='st'>"GBS"</span>) <span class='co'># Group B Streptococci</span></div><div class='output co'>#&gt; Class 'mo'
#&gt; [1] B_STRPTC_GRB</div><div class='input'>
<span class='co'># guess_mo is an alias of as.mo and works the same</span> <span class='co'># guess_mo is an alias of as.mo and works the same</span>
<span class='fu'>guess_mo</span>(<span class='st'>"S. epidermidis"</span>) <span class='co'># will remain species: B_STPHY_EPI</span> <span class='fu'>guess_mo</span>(<span class='st'>"S. epidermidis"</span>) <span class='co'># will remain species: B_STPHY_EPI</span></div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>guess_mo</span>(<span class='st'>"S. epidermidis"</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># will not remain species: B_STPHY_CNS</span> #&gt; [1] B_STPHY_EPI</div><div class='input'><span class='fu'>guess_mo</span>(<span class='st'>"S. epidermidis"</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># will not remain species: B_STPHY_CNS</span></div><div class='output co'>#&gt; Class 'mo'
#&gt; [1] B_STPHY_CNS</div><div class='input'>
<span class='fu'>guess_mo</span>(<span class='st'>"S. pyogenes"</span>) <span class='co'># will remain species: B_STRPTC_PYO</span> <span class='fu'>guess_mo</span>(<span class='st'>"S. pyogenes"</span>) <span class='co'># will remain species: B_STRPTC_PYO</span></div><div class='output co'>#&gt; Class 'mo'
<span class='fu'>guess_mo</span>(<span class='st'>"S. pyogenes"</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># will not remain species: B_STRPTC_GRA</span> #&gt; [1] B_STRPTC_PYO</div><div class='input'><span class='fu'>guess_mo</span>(<span class='st'>"S. pyogenes"</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># will not remain species: B_STRPTC_GRA</span></div><div class='output co'>#&gt; Class 'mo'
#&gt; [1] B_STRPTC_GRA</div><div class='input'>
<span class='co'># Use mo_* functions to get a specific property based on `mo`</span> <span class='co'># Use mo_* functions to get a specific property based on `mo`</span>
<span class='no'>Ecoli</span> <span class='kw'>&lt;-</span> <span class='fu'>as.mo</span>(<span class='st'>"E. coli"</span>) <span class='co'># returns `B_ESCHR_COL`</span> <span class='no'>Ecoli</span> <span class='kw'>&lt;-</span> <span class='fu'>as.mo</span>(<span class='st'>"E. coli"</span>) <span class='co'># returns `B_ESCHR_COL`</span>
<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='no'>Ecoli</span>) <span class='co'># returns "Escherichia"</span> <span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='no'>Ecoli</span>) <span class='co'># returns "Escherichia"</span></div><div class='output co'>#&gt; [1] "Escherichia"</div><div class='input'><span class='fu'><a href='mo_property.html'>mo_gramstain</a></span>(<span class='no'>Ecoli</span>) <span class='co'># returns "Gram negative"</span></div><div class='output co'>#&gt; [1] "Gram-negatief"</div><div class='input'><span class='co'># but it uses as.mo internally too, so you could also just use:</span>
<span class='fu'><a href='mo_property.html'>mo_gramstain</a></span>(<span class='no'>Ecoli</span>) <span class='co'># returns "Gram negative"</span> <span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='st'>"E. coli"</span>) <span class='co'># returns "Escherichia"</span></div><div class='output co'>#&gt; [1] "Escherichia"</div><div class='input'>
<span class='co'># but it uses as.mo internally too, so you could also just use:</span>
<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='st'>"E. coli"</span>) <span class='co'># returns "Escherichia"</span>
</div></span><span class='co'># NOT RUN {</span>
<span class='co'># }</span><span class='co'># NOT RUN {</span>
<span class='no'>df</span>$<span class='no'>mo</span> <span class='kw'>&lt;-</span> <span class='fu'>as.mo</span>(<span class='no'>df</span>$<span class='no'>microorganism_name</span>) <span class='no'>df</span>$<span class='no'>mo</span> <span class='kw'>&lt;-</span> <span class='fu'>as.mo</span>(<span class='no'>df</span>$<span class='no'>microorganism_name</span>)
<span class='co'># the select function of tidyverse is also supported:</span> <span class='co'># the select function of tidyverse is also supported:</span>

File diff suppressed because it is too large Load Diff

View File

@ -230,22 +230,21 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># What's the ATC of amoxicillin?</span>
<span class='co'># What's the ATC of amoxicillin?</span> <span class='fu'><a href='as.atc.html'>guess_atc</a></span>(<span class='st'>"Amoxicillin"</span>)</div><div class='output co'>#&gt; Class 'atc'
<span class='fu'><a href='as.atc.html'>guess_atc</a></span>(<span class='st'>"Amoxicillin"</span>) #&gt; [1] J01CA04</div><div class='input'><span class='co'># [1] "J01CA04"</span>
<span class='co'># [1] "J01CA04"</span>
<span class='co'># oral DDD (Defined Daily Dose) of amoxicillin</span> <span class='co'># oral DDD (Defined Daily Dose) of amoxicillin</span>
<span class='fu'>atc_property</span>(<span class='st'>"J01CA04"</span>, <span class='st'>"DDD"</span>, <span class='st'>"O"</span>) <span class='fu'>atc_property</span>(<span class='st'>"J01CA04"</span>, <span class='st'>"DDD"</span>, <span class='st'>"O"</span>)</div><div class='output co'>#&gt; [1] 1.5</div><div class='input'><span class='co'># parenteral DDD (Defined Daily Dose) of amoxicillin</span>
<span class='co'># parenteral DDD (Defined Daily Dose) of amoxicillin</span> <span class='fu'>atc_property</span>(<span class='st'>"J01CA04"</span>, <span class='st'>"DDD"</span>, <span class='st'>"P"</span>)</div><div class='output co'>#&gt; [1] 3</div><div class='input'>
<span class='fu'>atc_property</span>(<span class='st'>"J01CA04"</span>, <span class='st'>"DDD"</span>, <span class='st'>"P"</span>) <span class='fu'>atc_property</span>(<span class='st'>"J01CA04"</span>, <span class='kw'>property</span> <span class='kw'>=</span> <span class='st'>"groups"</span>) <span class='co'># search hierarchical groups of amoxicillin</span></div><div class='output co'>#&gt; [1] "ANTIINFECTIVES FOR SYSTEMIC USE"
#&gt; [2] "ANTIBACTERIALS FOR SYSTEMIC USE"
<span class='fu'>atc_property</span>(<span class='st'>"J01CA04"</span>, <span class='kw'>property</span> <span class='kw'>=</span> <span class='st'>"groups"</span>) <span class='co'># search hierarchical groups of amoxicillin</span> #&gt; [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS"
<span class='co'># [1] "ANTIINFECTIVES FOR SYSTEMIC USE"</span> #&gt; [4] "Penicillins with extended spectrum" </div><div class='input'># [1] "ANTIINFECTIVES FOR SYSTEMIC USE"
<span class='co'># [2] "ANTIBACTERIALS FOR SYSTEMIC USE"</span> # [2] "ANTIBACTERIALS FOR SYSTEMIC USE"
<span class='co'># [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS"</span> # [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS"
<span class='co'># [4] "Penicillins with extended spectrum"</span> # [4] "Penicillins with extended spectrum"
<span class='co'># }</span></pre> </div></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -231,28 +231,18 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># septic_patients is a data set available in the AMR package. It is true, genuine data.</span>
<span class='co'># septic_patients is a data set available in the AMR package. It is true, genuine data.</span> ?<span class='no'>septic_patients</span></div><div class='output co'>#&gt; <span class='message'>Rendering development documentation for 'septic_patients'</span></div><div class='input'>
?<span class='no'>septic_patients</span>
<span class='co'># Count resistant isolates</span> <span class='co'># Count resistant isolates</span>
<span class='fu'>count_R</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>) <span class='fu'>count_R</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 683</div><div class='input'><span class='fu'>count_IR</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 686</div><div class='input'>
<span class='fu'>count_IR</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)
<span class='co'># Or susceptible isolates</span> <span class='co'># Or susceptible isolates</span>
<span class='fu'>count_S</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>) <span class='fu'>count_S</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 486</div><div class='input'><span class='fu'>count_SI</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 489</div><div class='input'>
<span class='fu'>count_SI</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)
<span class='co'># Count all available isolates</span> <span class='co'># Count all available isolates</span>
<span class='fu'>count_all</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>) <span class='fu'>count_all</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 1172</div><div class='input'><span class='fu'>n_rsi</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 1172</div><div class='input'>
<span class='fu'>n_rsi</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)
<span class='co'># Since n_rsi counts available isolates, you can</span> <span class='co'># Since n_rsi counts available isolates, you can</span>
<span class='co'># calculate back to count e.g. non-susceptible isolates.</span> <span class='co'># calculate back to count e.g. non-susceptible isolates.</span>
<span class='co'># This results in the same:</span> <span class='co'># This results in the same:</span>
<span class='fu'>count_IR</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>) <span class='fu'>count_IR</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 686</div><div class='input'><span class='fu'><a href='portion.html'>portion_IR</a></span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>) * <span class='fu'>n_rsi</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 686</div><div class='input'>
<span class='fu'><a href='portion.html'>portion_IR</a></span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>) * <span class='fu'>n_rsi</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>) <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
@ -261,34 +251,50 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
<span class='kw'>S</span> <span class='kw'>=</span> <span class='fu'>count_S</span>(<span class='no'>cipr</span>), <span class='kw'>S</span> <span class='kw'>=</span> <span class='fu'>count_S</span>(<span class='no'>cipr</span>),
<span class='kw'>n1</span> <span class='kw'>=</span> <span class='fu'>count_all</span>(<span class='no'>cipr</span>), <span class='co'># the actual total; sum of all three</span> <span class='kw'>n1</span> <span class='kw'>=</span> <span class='fu'>count_all</span>(<span class='no'>cipr</span>), <span class='co'># the actual total; sum of all three</span>
<span class='kw'>n2</span> <span class='kw'>=</span> <span class='fu'>n_rsi</span>(<span class='no'>cipr</span>), <span class='co'># same - analogous to n_distinct</span> <span class='kw'>n2</span> <span class='kw'>=</span> <span class='fu'>n_rsi</span>(<span class='no'>cipr</span>), <span class='co'># same - analogous to n_distinct</span>
<span class='kw'>total</span> <span class='kw'>=</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/n.html'>n</a></span>()) <span class='co'># NOT the amount of tested isolates!</span> <span class='kw'>total</span> <span class='kw'>=</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/n.html'>n</a></span>()) <span class='co'># NOT the amount of tested isolates!</span></div><div class='output co'>#&gt; <span style='color: #949494;'># A tibble: 4 x 7</span><span>
#&gt; hospital_id R I S n1 n2 total
#&gt; </span><span style='color: #949494;font-style: italic;'>&lt;fct&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span>
#&gt; </span><span style='color: #BCBCBC;'>1</span><span> A 26 3 178 207 207 321
#&gt; </span><span style='color: #BCBCBC;'>2</span><span> B 85 35 379 499 499 663
#&gt; </span><span style='color: #BCBCBC;'>3</span><span> C 41 22 139 202 202 254
#&gt; </span><span style='color: #BCBCBC;'>4</span><span> D 76 9 416 501 501 762</div><div class='input'>
<span class='co'># Count co-resistance between amoxicillin/clav acid and gentamicin,</span> <span class='co'># Count co-resistance between amoxicillin/clav acid and gentamicin,</span>
<span class='co'># so we can see that combination therapy does a lot more than mono therapy.</span> <span class='co'># so we can see that combination therapy does a lot more than mono therapy.</span>
<span class='co'># Please mind that `portion_S` calculates percentages right away instead.</span> <span class='co'># Please mind that `portion_S` calculates percentages right away instead.</span>
<span class='fu'>count_S</span>(<span class='no'>septic_patients</span>$<span class='no'>amcl</span>) <span class='co'># S = 1057 (67.1%)</span> <span class='fu'>count_S</span>(<span class='no'>septic_patients</span>$<span class='no'>amcl</span>) <span class='co'># S = 1057 (67.1%)</span></div><div class='output co'>#&gt; [1] 1291</div><div class='input'><span class='fu'>count_all</span>(<span class='no'>septic_patients</span>$<span class='no'>amcl</span>) <span class='co'># n = 1576</span></div><div class='output co'>#&gt; [1] 1828</div><div class='input'>
<span class='fu'>count_all</span>(<span class='no'>septic_patients</span>$<span class='no'>amcl</span>) <span class='co'># n = 1576</span> <span class='fu'>count_S</span>(<span class='no'>septic_patients</span>$<span class='no'>gent</span>) <span class='co'># S = 1372 (74.0%)</span></div><div class='output co'>#&gt; [1] 1372</div><div class='input'><span class='fu'>count_all</span>(<span class='no'>septic_patients</span>$<span class='no'>gent</span>) <span class='co'># n = 1855</span></div><div class='output co'>#&gt; [1] 1855</div><div class='input'>
<span class='fu'>count_S</span>(<span class='no'>septic_patients</span>$<span class='no'>gent</span>) <span class='co'># S = 1372 (74.0%)</span>
<span class='fu'>count_all</span>(<span class='no'>septic_patients</span>$<span class='no'>gent</span>) <span class='co'># n = 1855</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/with'>with</a></span>(<span class='no'>septic_patients</span>, <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/with'>with</a></span>(<span class='no'>septic_patients</span>,
<span class='fu'>count_S</span>(<span class='no'>amcl</span>, <span class='no'>gent</span>)) <span class='co'># S = 1396 (92.0%)</span> <span class='fu'>count_S</span>(<span class='no'>amcl</span>, <span class='no'>gent</span>)) <span class='co'># S = 1396 (92.0%)</span></div><div class='output co'>#&gt; [1] 1609</div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/with'>with</a></span>(<span class='no'>septic_patients</span>, <span class='co'># n = 1517</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/with'>with</a></span>(<span class='no'>septic_patients</span>, <span class='co'># n = 1517</span> <span class='fu'>n_rsi</span>(<span class='no'>amcl</span>, <span class='no'>gent</span>))</div><div class='output co'>#&gt; [1] 1747</div><div class='input'>
<span class='fu'>n_rsi</span>(<span class='no'>amcl</span>, <span class='no'>gent</span>))
<span class='co'># Get portions S/I/R immediately of all rsi columns</span> <span class='co'># Get portions S/I/R immediately of all rsi columns</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>count_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>) <span class='fu'>count_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</div><div class='output co'>#&gt; Interpretation Antibiotic Value
#&gt; 1 S amox 486
#&gt; 2 I amox 3
#&gt; 3 R amox 683
#&gt; 4 S cipr 1112
#&gt; 5 I cipr 69
#&gt; 6 R cipr 228</div><div class='input'>
<span class='co'># It also supports grouping variables</span> <span class='co'># It also supports grouping variables</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>hospital_id</span>, <span class='no'>amox</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>hospital_id</span>, <span class='no'>amox</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>count_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>) <span class='fu'>count_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</div><div class='output co'>#&gt; </span><span style='color: #949494;'># A tibble: 24 x 4</span><span>
#&gt; Interpretation hospital_id Antibiotic Value
<span class='co'># }</span></pre> #&gt; </span><span style='color: #949494;font-style: italic;'>&lt;ord&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;fct&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;chr&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 1</span><span> S A amox 63
#&gt; </span><span style='color: #BCBCBC;'> 2</span><span> S B amox 141
#&gt; </span><span style='color: #BCBCBC;'> 3</span><span> S C amox 59
#&gt; </span><span style='color: #BCBCBC;'> 4</span><span> S D amox 223
#&gt; </span><span style='color: #BCBCBC;'> 5</span><span> I A amox 0
#&gt; </span><span style='color: #BCBCBC;'> 6</span><span> I B amox 1
#&gt; </span><span style='color: #BCBCBC;'> 7</span><span> I C amox 0
#&gt; </span><span style='color: #BCBCBC;'> 8</span><span> I D amox 2
#&gt; </span><span style='color: #BCBCBC;'> 9</span><span> R A amox 87
#&gt; </span><span style='color: #BCBCBC;'>10</span><span> R B amox 231
#&gt; </span><span style='color: #949494;'># ... with 14 more rows</span><span></div><div class='input'>
</div></span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -309,9 +309,49 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='no'>a</span> <span class='kw'>&lt;-</span> <span class='fu'>eucast_rules</span>(<span class='no'>septic_patients</span>)</div><div class='output co'>#&gt; <span class='message'><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>mo</span><span style='color: #0000BB;'>` as input for `col_mo`.</span><span></span></div><div class='output co'>#&gt; <span class='warning'>Warning: These columns do not exist and will be ignored: azlo, aztr, cefa, cfra, clar, dapt, erta, fusi, levo, linc, mezl, mino, nali, neom, neti, novo, norf, oflo, pipe, poly, pris, qida, roxi, siso, tica.</span>
<span class='no'>a</span> <span class='kw'>&lt;-</span> <span class='fu'>eucast_rules</span>(<span class='no'>septic_patients</span>) #&gt; <span class='warning'>THIS MAY STRONGLY INFLUENCE THE OUTCOME.</span></div><div class='output co'>#&gt;
#&gt; Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
#&gt; </span><span style='font-weight: bold;'>
#&gt; EUCAST Clinical Breakpoints (v8.1, 2018)
#&gt; </span><span>Enterobacteriales (Order)</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Staphylococcus</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Enterococcus</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Streptococcus</span><span> groups A, B, C, G</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Streptococcus pneumoniae</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Viridans group streptococci</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Haemophilus influenzae</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Moraxella catarrhalis</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Anaerobic Gram positives</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Anaerobic Gram negatives</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Pasteurella multocida</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Campylobacter jejuni</span><span> and </span><span style='font-style: italic;'>C. coli</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Aerococcus sanguinicola</span><span> and </span><span style='font-style: italic;'>A. urinae</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Kingella kingae</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-weight: bold;'>
#&gt; EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
#&gt; </span><span>Table 1: Intrinsic resistance in </span><span style='font-style: italic;'>Enterobacteriaceae</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 3: Intrinsic resistance in other Gram-negative bacteria</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 4: Intrinsic resistance in Gram-positive bacteria</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 9: Interpretive rules for B-lactam agents and Gram-negative rods</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 12: Interpretive rules for aminoglycosides</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 13: Interpretive rules for quinolones</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-weight: bold;'>
#&gt; Other rules
#&gt; </span><span>Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-weight: bold;'>
#&gt; =&gt; EUCAST rules affected 1,980 out of 2,000 rows -&gt; </span><span style='color: #00BB00;font-weight: bold;'>changed 0 test results.
#&gt;
#&gt; </span><span></div><div class='input'>
<span class='no'>a</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></span>(<span class='kw'>mo</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"Staphylococcus aureus"</span>, <span class='no'>a</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></span>(<span class='kw'>mo</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"Staphylococcus aureus"</span>,
<span class='st'>"Enterococcus faecalis"</span>, <span class='st'>"Enterococcus faecalis"</span>,
<span class='st'>"Escherichia coli"</span>, <span class='st'>"Escherichia coli"</span>,
@ -326,24 +366,72 @@
<span class='kw'>cfox</span> <span class='kw'>=</span> <span class='st'>"S"</span>, <span class='co'># Cefoxitin</span> <span class='kw'>cfox</span> <span class='kw'>=</span> <span class='st'>"S"</span>, <span class='co'># Cefoxitin</span>
<span class='kw'>stringsAsFactors</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>) <span class='kw'>stringsAsFactors</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
<span class='no'>a</span> <span class='no'>a</span></div><div class='output co'>#&gt; mo vanc amox coli cfta cfur peni cfox
<span class='co'># mo vanc amox coli cfta cfur peni cfox</span> #&gt; 1 Staphylococcus aureus - - - - - S S
#&gt; 2 Enterococcus faecalis - - - - - S S
#&gt; 3 Escherichia coli - - - - - S S
#&gt; 4 Klebsiella pneumoniae - - - - - S S
#&gt; 5 Pseudomonas aeruginosa - - - - - S S</div><div class='input'><span class='co'># mo vanc amox coli cfta cfur peni cfox</span>
<span class='co'># 1 Staphylococcus aureus - - - - - S S</span> <span class='co'># 1 Staphylococcus aureus - - - - - S S</span>
<span class='co'># 2 Enterococcus faecalis - - - - - S S</span> <span class='co'># 2 Enterococcus faecalis - - - - - S S</span>
<span class='co'># 3 Escherichia coli - - - - - S S</span> <span class='co'># 3 Escherichia coli - - - - - S S</span>
<span class='co'># 4 Klebsiella pneumoniae - - - - - S S</span> <span class='co'># 4 Klebsiella pneumoniae - - - - - S S</span>
<span class='co'># 5 Pseudomonas aeruginosa - - - - - S S</span> <span class='co'># 5 Pseudomonas aeruginosa - - - - - S S</span>
<span class='no'>b</span> <span class='kw'>&lt;-</span> <span class='fu'>eucast_rules</span>(<span class='no'>a</span>, <span class='st'>"mo"</span>) <span class='co'># 18 results are forced as R or S</span> <span class='no'>b</span> <span class='kw'>&lt;-</span> <span class='fu'>eucast_rules</span>(<span class='no'>a</span>, <span class='st'>"mo"</span>) <span class='co'># 18 results are forced as R or S</span></div><div class='output co'>#&gt; <span class='warning'>Warning: These columns do not exist and will be ignored: amcl, amik, ampi, azit, azlo, aztr, cefa, cfra, cfep, cfot, cftr, chlo, cipr, clar, clin, clox, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, novo, norf, oflo, oxac, pipe, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu.</span>
#&gt; <span class='warning'>THIS MAY STRONGLY INFLUENCE THE OUTCOME.</span></div><div class='output co'>#&gt;
<span class='no'>b</span> #&gt; Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)</div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>amox</span><span style='color: #0000BB;'>` as input for ampicillin (J01CA01) since many EUCAST rules depend on it.</span><span></span></div><div class='output co'>#&gt; </span><span style='font-weight: bold;'>
<span class='co'># mo vanc amox coli cfta cfur peni cfox</span> #&gt; EUCAST Clinical Breakpoints (v8.1, 2018)
<span class='co'># 1 Staphylococcus aureus - S R R S S S</span> #&gt; </span><span>Enterobacteriales (Order)</span><span style='color: #00BB00;'> (no changes)
<span class='co'># 2 Enterococcus faecalis - - R R R S R</span> #&gt; </span><span style='font-style: italic;'>Staphylococcus</span><span style='color: #0000BB;'> (2 changes)
<span class='co'># 3 Escherichia coli R - - - - R S</span> #&gt; </span><span style='font-style: italic;'>Enterococcus</span><span style='color: #00BB00;'> (no changes)
<span class='co'># 4 Klebsiella pneumoniae R R - - - R S</span> #&gt; </span><span style='font-style: italic;'>Streptococcus</span><span> groups A, B, C, G</span><span style='color: #00BB00;'> (no changes)
<span class='co'># 5 Pseudomonas aeruginosa R R - - R R R</span> #&gt; </span><span style='font-style: italic;'>Streptococcus pneumoniae</span><span style='color: #00BB00;'> (no changes)
<span class='co'># }</span></pre> #&gt; </span><span>Viridans group streptococci</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Haemophilus influenzae</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Moraxella catarrhalis</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Anaerobic Gram positives</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Anaerobic Gram negatives</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Pasteurella multocida</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Campylobacter jejuni</span><span> and </span><span style='font-style: italic;'>C. coli</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Aerococcus sanguinicola</span><span> and </span><span style='font-style: italic;'>A. urinae</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-style: italic;'>Kingella kingae</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-weight: bold;'>
#&gt; EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
#&gt; </span><span>Table 1: Intrinsic resistance in </span><span style='font-style: italic;'>Enterobacteriaceae</span><span style='color: #0000BB;'> (5 changes)
#&gt; </span><span>Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria</span><span style='color: #0000BB;'> (5 changes)
#&gt; </span><span>Table 3: Intrinsic resistance in other Gram-negative bacteria</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 4: Intrinsic resistance in Gram-positive bacteria</span><span style='color: #0000BB;'> (6 changes)
#&gt; </span><span>Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 9: Interpretive rules for B-lactam agents and Gram-negative rods</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 12: Interpretive rules for aminoglycosides</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Table 13: Interpretive rules for quinolones</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-weight: bold;'>
#&gt; Other rules
#&gt; </span><span>Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span>Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S</span><span style='color: #00BB00;'> (no changes)
#&gt; </span><span style='font-weight: bold;'>
#&gt; =&gt; EUCAST rules affected 5 out of 5 rows -&gt; </span><span style='color: #0000BB;font-weight: bold;'>changed 18 test results.
#&gt;
#&gt; </span><span></div><div class='input'>
<span class='no'>b</span></div><div class='output co'>#&gt; mo vanc amox coli cfta cfur peni cfox
#&gt; 1 Staphylococcus aureus - S R R S S S
#&gt; 2 Enterococcus faecalis - - R R R S R
#&gt; 3 Escherichia coli R - - - - R S
#&gt; 4 Klebsiella pneumoniae R R - - - R S
#&gt; 5 Pseudomonas aeruginosa R R - - R R R</div><div class='input'># mo vanc amox coli cfta cfur peni cfox
# 1 Staphylococcus aureus - S R R S S S
# 2 Enterococcus faecalis - - R R R S R
# 3 Escherichia coli R - - - - R S
# 4 Klebsiella pneumoniae R R - - - R S
# 5 Pseudomonas aeruginosa R R - - R R R
</div></span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -305,44 +305,222 @@ top_freq can be used to get the top/bottom n items of a frequency table, with co
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='co'># this all gives the same result:</span> <span class='co'># this all gives the same result:</span>
<span class='fu'>freq</span>(<span class='no'>septic_patients</span>$<span class='no'>hospital_id</span>) <span class='fu'>freq</span>(<span class='no'>septic_patients</span>$<span class='no'>hospital_id</span>)</div><div class='output co'>#&gt;
<span class='fu'>freq</span>(<span class='no'>septic_patients</span>[, <span class='st'>"hospital_id"</span>]) #&gt;
<span class='no'>septic_patients</span>$<span class='no'>hospital_id</span> <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>() #&gt; **Frequency table**
<span class='no'>septic_patients</span>[, <span class='st'>"hospital_id"</span>] <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>() #&gt;
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='st'>"hospital_id"</span>) #&gt;
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>hospital_id</span>) <span class='co'>#&lt;- easiest to remember (tidyverse)</span> #&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:----|-----:|-------:|----------:|------------:|
#&gt; |1 |D | 762| 38.1%| 762| 38.1%|
#&gt; |2 |B | 663| 33.2%| 1,425| 71.3%|
#&gt; |3 |A | 321| 16.1%| 1,746| 87.3%|
#&gt; |4 |C | 254| 12.7%| 2,000| 100.0%|
#&gt;
#&gt; </div><div class='input'><span class='fu'>freq</span>(<span class='no'>septic_patients</span>[, <span class='st'>"hospital_id"</span>])</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:----|-----:|-------:|----------:|------------:|
#&gt; |1 |D | 762| 38.1%| 762| 38.1%|
#&gt; |2 |B | 663| 33.2%| 1,425| 71.3%|
#&gt; |3 |A | 321| 16.1%| 1,746| 87.3%|
#&gt; |4 |C | 254| 12.7%| 2,000| 100.0%|
#&gt;
#&gt; </div><div class='input'><span class='no'>septic_patients</span>$<span class='no'>hospital_id</span> <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>()</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:----|-----:|-------:|----------:|------------:|
#&gt; |1 |D | 762| 38.1%| 762| 38.1%|
#&gt; |2 |B | 663| 33.2%| 1,425| 71.3%|
#&gt; |3 |A | 321| 16.1%| 1,746| 87.3%|
#&gt; |4 |C | 254| 12.7%| 2,000| 100.0%|
#&gt;
#&gt; </div><div class='input'><span class='no'>septic_patients</span>[, <span class='st'>"hospital_id"</span>] <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>()</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:----|-----:|-------:|----------:|------------:|
#&gt; |1 |D | 762| 38.1%| 762| 38.1%|
#&gt; |2 |B | 663| 33.2%| 1,425| 71.3%|
#&gt; |3 |A | 321| 16.1%| 1,746| 87.3%|
#&gt; |4 |C | 254| 12.7%| 2,000| 100.0%|
#&gt;
#&gt; </div><div class='input'><span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='st'>"hospital_id"</span>)</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table of `hospital_id`**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:----|-----:|-------:|----------:|------------:|
#&gt; |1 |D | 762| 38.1%| 762| 38.1%|
#&gt; |2 |B | 663| 33.2%| 1,425| 71.3%|
#&gt; |3 |A | 321| 16.1%| 1,746| 87.3%|
#&gt; |4 |C | 254| 12.7%| 2,000| 100.0%|
#&gt;
#&gt; </div><div class='input'><span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>hospital_id</span>) <span class='co'>#&lt;- easiest to remember (tidyverse)</span></div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table of `hospital_id`**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:----|-----:|-------:|----------:|------------:|
#&gt; |1 |D | 762| 38.1%| 762| 38.1%|
#&gt; |2 |B | 663| 33.2%| 1,425| 71.3%|
#&gt; |3 |A | 321| 16.1%| 1,746| 87.3%|
#&gt; |4 |C | 254| 12.7%| 2,000| 100.0%|
#&gt;
#&gt; </div><div class='input'>
<span class='co'># you could also use `select` or `pull` to get your variables</span> <span class='co'># you could also use `select` or `pull` to get your variables</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>hospital_id</span> <span class='kw'>==</span> <span class='st'>"A"</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>hospital_id</span> <span class='kw'>==</span> <span class='st'>"A"</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>mo</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>mo</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>() <span class='fu'>freq</span>()</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:------------|-----:|-------:|----------:|------------:|
#&gt; |1 |B_ESCHR_COL | 62| 19.3%| 62| 19.3%|
#&gt; |2 |B_STPHY_EPI | 46| 14.3%| 108| 33.6%|
#&gt; |3 |B_STPHY_CNS | 38| 11.8%| 146| 45.5%|
#&gt; |4 |B_STPHY_AUR | 35| 10.9%| 181| 56.4%|
#&gt; |5 |B_STPHY_HOM | 25| 7.8%| 206| 64.2%|
#&gt; |6 |B_STRPTC_PNE | 12| 3.7%| 218| 67.9%|
#&gt; |7 |B_PROTS_MIR | 11| 3.4%| 229| 71.3%|
#&gt; |8 |B_ENTRC_FAE | 10| 3.1%| 239| 74.5%|
#&gt; |9 |B_KLBSL_PNE | 8| 2.5%| 247| 76.9%|
#&gt; |10 |B_STRPTC_PYO | 7| 2.2%| 254| 79.1%|
#&gt; |11 |B_BCTRD_FRA | 5| 1.6%| 259| 80.7%|
#&gt; |12 |B_KLBSL_OXY | 5| 1.6%| 264| 82.2%|
#&gt; |13 |B_STRPTC | 5| 1.6%| 269| 83.8%|
#&gt; |14 |B_ENTRC_IUM | 4| 1.2%| 273| 85.0%|
#&gt; |15 |B_STRPTC_MIT | 4| 1.2%| 277| 86.3%|
#&gt; |16 |B_CRYNB | 3| 0.9%| 280| 87.2%|
#&gt; |17 |B_PDMNS_AER | 3| 0.9%| 283| 88.2%|
#&gt; |18 |B_STPHY_CAP | 3| 0.9%| 286| 89.1%|
#&gt; |19 |B_STRPTC_DYS | 3| 0.9%| 289| 90.0%|
#&gt; |20 |F_CANDD_GLB | 3| 0.9%| 292| 91.0%|
#&gt; |21 |B_ACNTB | 2| 0.6%| 294| 91.6%|
#&gt; |22 |B_ENTRB_CLO | 2| 0.6%| 296| 92.2%|
#&gt; |23 |B_HMPHL_INF | 2| 0.6%| 298| 92.8%|
#&gt; |24 |B_MCRCCC | 2| 0.6%| 300| 93.5%|
#&gt; |25 |B_PROTS_VUL | 2| 0.6%| 302| 94.1%|
#&gt; |26 |B_SERRT_MAR | 2| 0.6%| 304| 94.7%|
#&gt; |27 |B_STPHY_COH | 2| 0.6%| 306| 95.3%|
#&gt; |28 |B_STRPTC_BOV | 2| 0.6%| 308| 96.0%|
#&gt; |29 |B_AMYCS_ODO | 1| 0.3%| 309| 96.3%|
#&gt; |30 |B_ARCCC_URI | 1| 0.3%| 310| 96.6%|
#&gt; |31 |B_CTRDM_PER | 1| 0.3%| 311| 96.9%|
#&gt; |32 |B_CTRDM_SEP | 1| 0.3%| 312| 97.2%|
#&gt; |33 |B_STPHY_SCH | 1| 0.3%| 313| 97.5%|
#&gt; |34 |B_STRPTC_AGA | 1| 0.3%| 314| 97.8%|
#&gt; |35 |B_STRPTC_EQU | 1| 0.3%| 315| 98.1%|
#&gt; |36 |B_STRPTC_GRA | 1| 0.3%| 316| 98.4%|
#&gt; |37 |B_STRPTC_GRB | 1| 0.3%| 317| 98.8%|
#&gt; |38 |B_STRPTC_SAN | 1| 0.3%| 318| 99.1%|
#&gt; |39 |B_VLLNL_PAR | 1| 0.3%| 319| 99.4%|
#&gt; |40 |F_CANDD_ALB | 1| 0.3%| 320| 99.7%|
#&gt; |41 |F_CANDD_TRO | 1| 0.3%| 321| 100.0%|
#&gt;
#&gt; </div><div class='input'>
<span class='co'># multiple selected variables will be pasted together</span> <span class='co'># multiple selected variables will be pasted together</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>left_join_microorganisms</span> <span class='kw'>%&gt;%</span> <span class='no'>left_join_microorganisms</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>hospital_id</span> <span class='kw'>==</span> <span class='st'>"A"</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>hospital_id</span> <span class='kw'>==</span> <span class='st'>"A"</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>genus</span>, <span class='no'>species</span>) <span class='fu'>freq</span>(<span class='no'>genus</span>, <span class='no'>species</span>)</div><div class='output co'>#&gt; <span class='message'>Joining, by = "mo"</span></div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table of `genus` and `species`**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:---------------------------------|-----:|-------:|----------:|------------:|
#&gt; |1 |Escherichia coli | 62| 19.3%| 62| 19.3%|
#&gt; |2 |Staphylococcus epidermidis | 46| 14.3%| 108| 33.6%|
#&gt; |3 |Staphylococcus coagulase negative | 38| 11.8%| 146| 45.5%|
#&gt; |4 |Staphylococcus aureus | 35| 10.9%| 181| 56.4%|
#&gt; |5 |Staphylococcus hominis | 25| 7.8%| 206| 64.2%|
#&gt; |6 |Streptococcus pneumoniae | 12| 3.7%| 218| 67.9%|
#&gt; |7 |Proteus mirabilis | 11| 3.4%| 229| 71.3%|
#&gt; |8 |Enterococcus faecalis | 10| 3.1%| 239| 74.5%|
#&gt; |9 |Klebsiella pneumoniae | 8| 2.5%| 247| 76.9%|
#&gt; |10 |Streptococcus pyogenes | 7| 2.2%| 254| 79.1%|
#&gt; |11 |Bacteroides fragilis | 5| 1.6%| 259| 80.7%|
#&gt; |12 |Klebsiella oxytoca | 5| 1.6%| 264| 82.2%|
#&gt; |13 |Streptococcus species | 5| 1.6%| 269| 83.8%|
#&gt; |14 |Enterococcus faecium | 4| 1.2%| 273| 85.0%|
#&gt; |15 |Streptococcus mitis | 4| 1.2%| 277| 86.3%|
#&gt; |16 |Candida glabrata | 3| 0.9%| 280| 87.2%|
#&gt; |17 |Corynebacterium species | 3| 0.9%| 283| 88.2%|
#&gt; |18 |Pseudomonas aeruginosa | 3| 0.9%| 286| 89.1%|
#&gt; |19 |Staphylococcus capitis | 3| 0.9%| 289| 90.0%|
#&gt; |20 |Streptococcus dysgalactiae | 3| 0.9%| 292| 91.0%|
#&gt; |21 |Acinetobacter species | 2| 0.6%| 294| 91.6%|
#&gt; |22 |Enterobacter cloacae | 2| 0.6%| 296| 92.2%|
#&gt; |23 |Haemophilus influenzae | 2| 0.6%| 298| 92.8%|
#&gt; |24 |Micrococcus species | 2| 0.6%| 300| 93.5%|
#&gt; |25 |Proteus vulgaris | 2| 0.6%| 302| 94.1%|
#&gt; |26 |Serratia marcescens | 2| 0.6%| 304| 94.7%|
#&gt; |27 |Staphylococcus cohnii | 2| 0.6%| 306| 95.3%|
#&gt; |28 |Streptococcus bovis | 2| 0.6%| 308| 96.0%|
#&gt; |29 |Actinomyces odontolyticus | 1| 0.3%| 309| 96.3%|
#&gt; |30 |Aerococcus urinae | 1| 0.3%| 310| 96.6%|
#&gt; |31 |Candida albicans | 1| 0.3%| 311| 96.9%|
#&gt; |32 |Candida tropicalis | 1| 0.3%| 312| 97.2%|
#&gt; |33 |Clostridium perfringens | 1| 0.3%| 313| 97.5%|
#&gt; |34 |Clostridium septicum | 1| 0.3%| 314| 97.8%|
#&gt; |35 |Staphylococcus schleiferi | 1| 0.3%| 315| 98.1%|
#&gt; |36 |Streptococcus agalactiae | 1| 0.3%| 316| 98.4%|
#&gt; |37 |Streptococcus equi | 1| 0.3%| 317| 98.8%|
#&gt; |38 |Streptococcus group A | 1| 0.3%| 318| 99.1%|
#&gt; |39 |Streptococcus group B | 1| 0.3%| 319| 99.4%|
#&gt; |40 |Streptococcus sanguinis | 1| 0.3%| 320| 99.7%|
#&gt; |41 |Veillonella parvula | 1| 0.3%| 321| 100.0%|
#&gt;
#&gt; </div><div class='input'>
<span class='co'># group a variable and analyse another</span> <span class='co'># group a variable and analyse another</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>gender</span>) <span class='fu'>freq</span>(<span class='no'>gender</span>)</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table of `gender` (grouped by `hospital_id`)**
#&gt;
#&gt;
#&gt; | |Group |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:-----|:----|-----:|-------:|----------:|------------:|
#&gt; |1 |1 |F | 148| 7.4%| 148| 7.4%|
#&gt; |2 | |M | 173| 8.7%| 321| 16.1%|
#&gt; |3 |2 |F | 332| 16.6%| 332| 16.6%|
#&gt; |4 | |M | 331| 16.6%| 663| 33.2%|
#&gt; |5 |3 |F | 121| 6.1%| 121| 6.1%|
#&gt; |6 | |M | 133| 6.7%| 254| 12.7%|
#&gt; |7 |4 |F | 368| 18.4%| 368| 18.4%|
#&gt; |8 | |M | 394| 19.7%| 762| 38.1%|
#&gt;
#&gt; </div><div class='input'>
<span class='co'># get top 10 bugs of hospital A as a vector</span> <span class='co'># get top 10 bugs of hospital A as a vector</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>hospital_id</span> <span class='kw'>==</span> <span class='st'>"A"</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>hospital_id</span> <span class='kw'>==</span> <span class='st'>"A"</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>mo</span>) <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>mo</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>top_freq</span>(<span class='fl'>10</span>) <span class='fu'>top_freq</span>(<span class='fl'>10</span>)</div><div class='output co'>#&gt; 62 46 38 35 25
#&gt; "B_ESCHR_COL" "B_STPHY_EPI" "B_STPHY_CNS" "B_STPHY_AUR" "B_STPHY_HOM"
#&gt; 12 11 10 8 7
#&gt; "B_STRPTC_PNE" "B_PROTS_MIR" "B_ENTRC_FAE" "B_KLBSL_PNE" "B_STRPTC_PYO" </div><div class='input'>
<span class='co'># save frequency table to an object</span> <span class='co'># save frequency table to an object</span>
<span class='no'>years</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>years</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
@ -351,8 +529,22 @@ top_freq can be used to get the top/bottom n items of a frequency table, with co
<span class='co'># show only the top 5</span> <span class='co'># show only the top 5</span>
<span class='no'>years</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/print'>print</a></span>(<span class='kw'>nmax</span> <span class='kw'>=</span> <span class='fl'>5</span>) <span class='no'>years</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/print'>print</a></span>(<span class='kw'>nmax</span> <span class='kw'>=</span> <span class='fl'>5</span>)</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table of `year`**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:----|-----:|-------:|----------:|------------:|
#&gt; |1 |2017 | 168| 8.4%| 168| 8.4%|
#&gt; |2 |2004 | 167| 8.4%| 335| 16.8%|
#&gt; |3 |2016 | 143| 7.2%| 478| 23.9%|
#&gt; |4 |2002 | 136| 6.8%| 614| 30.7%|
#&gt; |5 |2003 | 135| 6.8%| 749| 37.5%|
#&gt;
#&gt; (omitted 11 entries, n = 1,251 [62.6%])
#&gt;
#&gt; </div><div class='input'>
<span class='co'># save to an object with formatted percentages</span> <span class='co'># save to an object with formatted percentages</span>
<span class='no'>years</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/format'>format</a></span>(<span class='no'>years</span>) <span class='no'>years</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/format'>format</a></span>(<span class='no'>years</span>)
@ -361,53 +553,372 @@ top_freq can be used to get the top/bottom n items of a frequency table, with co
<span class='co'># print a histogram of numeric values</span> <span class='co'># print a histogram of numeric values</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/hist'>hist</a></span>() <span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/hist'>hist</a></span>()</div><div class='img'><img src='freq-1.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># or print all points to a regular plot</span> <span class='co'># or print all points to a regular plot</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/plot'>plot</a></span>() <span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/plot'>plot</a></span>()</div><div class='img'><img src='freq-2.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># transform to a data.frame or tibble</span> <span class='co'># transform to a data.frame or tibble</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/as.data.frame'>as.data.frame</a></span>() <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/as.data.frame'>as.data.frame</a></span>()</div><div class='output co'>#&gt; item count percent cum_count cum_percent
#&gt; 1 83 102 0.0510 102 0.0510
#&gt; 2 80 75 0.0375 177 0.0885
#&gt; 3 75 72 0.0360 249 0.1245
#&gt; 4 79 72 0.0360 321 0.1605
#&gt; 5 78 70 0.0350 391 0.1955
#&gt; 6 76 65 0.0325 456 0.2280
#&gt; 7 82 62 0.0310 518 0.2590
#&gt; 8 86 61 0.0305 579 0.2895
#&gt; 9 81 58 0.0290 637 0.3185
#&gt; 10 87 57 0.0285 694 0.3470
#&gt; 11 74 54 0.0270 748 0.3740
#&gt; 12 73 53 0.0265 801 0.4005
#&gt; 13 77 52 0.0260 853 0.4265
#&gt; 14 67 51 0.0255 904 0.4520
#&gt; 15 88 51 0.0255 955 0.4775
#&gt; 16 70 50 0.0250 1005 0.5025
#&gt; 17 69 49 0.0245 1054 0.5270
#&gt; 18 71 47 0.0235 1101 0.5505
#&gt; 19 72 45 0.0225 1146 0.5730
#&gt; 20 65 43 0.0215 1189 0.5945
#&gt; 21 66 42 0.0210 1231 0.6155
#&gt; 22 85 42 0.0210 1273 0.6365
#&gt; 23 68 41 0.0205 1314 0.6570
#&gt; 24 47 39 0.0195 1353 0.6765
#&gt; 25 90 35 0.0175 1388 0.6940
#&gt; 26 89 34 0.0170 1422 0.7110
#&gt; 27 84 33 0.0165 1455 0.7275
#&gt; 28 62 32 0.0160 1487 0.7435
#&gt; 29 59 31 0.0155 1518 0.7590
#&gt; 30 64 31 0.0155 1549 0.7745
#&gt; 31 57 29 0.0145 1578 0.7890
#&gt; 32 63 28 0.0140 1606 0.8030
#&gt; 33 51 27 0.0135 1633 0.8165
#&gt; 34 52 25 0.0125 1658 0.8290
#&gt; 35 60 25 0.0125 1683 0.8415
#&gt; 36 53 23 0.0115 1706 0.8530
#&gt; 37 58 23 0.0115 1729 0.8645
#&gt; 38 50 22 0.0110 1751 0.8755
#&gt; 39 56 21 0.0105 1772 0.8860
#&gt; 40 45 20 0.0100 1792 0.8960
#&gt; 41 55 17 0.0085 1809 0.9045
#&gt; 42 61 17 0.0085 1826 0.9130
#&gt; 43 93 16 0.0080 1842 0.9210
#&gt; 44 43 15 0.0075 1857 0.9285
#&gt; 45 44 13 0.0065 1870 0.9350
#&gt; 46 46 13 0.0065 1883 0.9415
#&gt; 47 41 10 0.0050 1893 0.9465
#&gt; 48 48 10 0.0050 1903 0.9515
#&gt; 49 30 9 0.0045 1912 0.9560
#&gt; 50 54 9 0.0045 1921 0.9605
#&gt; 51 92 9 0.0045 1930 0.9650
#&gt; 52 91 8 0.0040 1938 0.9690
#&gt; 53 42 7 0.0035 1945 0.9725
#&gt; 54 38 6 0.0030 1951 0.9755
#&gt; 55 94 6 0.0030 1957 0.9785
#&gt; 56 20 4 0.0020 1961 0.9805
#&gt; 57 39 4 0.0020 1965 0.9825
#&gt; 58 49 4 0.0020 1969 0.9845
#&gt; 59 19 3 0.0015 1972 0.9860
#&gt; 60 29 3 0.0015 1975 0.9875
#&gt; 61 33 3 0.0015 1978 0.9890
#&gt; 62 37 3 0.0015 1981 0.9905
#&gt; 63 40 3 0.0015 1984 0.9920
#&gt; 64 18 2 0.0010 1986 0.9930
#&gt; 65 24 2 0.0010 1988 0.9940
#&gt; 66 31 2 0.0010 1990 0.9950
#&gt; 67 36 2 0.0010 1992 0.9960
#&gt; 68 97 2 0.0010 1994 0.9970
#&gt; 69 14 1 0.0005 1995 0.9975
#&gt; 70 22 1 0.0005 1996 0.9980
#&gt; 71 32 1 0.0005 1997 0.9985
#&gt; 72 34 1 0.0005 1998 0.9990
#&gt; 73 35 1 0.0005 1999 0.9995
#&gt; 74 95 1 0.0005 2000 1.0000</div><div class='input'>
<span class='co'># or transform (back) to a vector</span> <span class='co'># or transform (back) to a vector</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/vector'>as.vector</a></span>() <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/vector'>as.vector</a></span>()</div><div class='output co'>#&gt; [1] 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83
#&gt; [25] 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83
#&gt; [49] 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83
#&gt; [73] 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83
#&gt; [97] 83 83 83 83 83 83 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
#&gt; [121] 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
#&gt; [145] 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
#&gt; [169] 80 80 80 80 80 80 80 80 80 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75
#&gt; [193] 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75
#&gt; [217] 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75
#&gt; [241] 75 75 75 75 75 75 75 75 75 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
#&gt; [265] 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
#&gt; [289] 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79
#&gt; [313] 79 79 79 79 79 79 79 79 79 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78
#&gt; [337] 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78
#&gt; [361] 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78
#&gt; [385] 78 78 78 78 78 78 78 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76
#&gt; [409] 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76
#&gt; [433] 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76
#&gt; [457] 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82
#&gt; [481] 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82 82
#&gt; [505] 82 82 82 82 82 82 82 82 82 82 82 82 82 82 86 86 86 86 86 86 86 86 86 86
#&gt; [529] 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86
#&gt; [553] 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86
#&gt; [577] 86 86 86 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81
#&gt; [601] 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81
#&gt; [625] 81 81 81 81 81 81 81 81 81 81 81 81 81 87 87 87 87 87 87 87 87 87 87 87
#&gt; [649] 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87
#&gt; [673] 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 74 74
#&gt; [697] 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74
#&gt; [721] 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74
#&gt; [745] 74 74 74 74 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73
#&gt; [769] 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73
#&gt; [793] 73 73 73 73 73 73 73 73 73 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77
#&gt; [817] 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77
#&gt; [841] 77 77 77 77 77 77 77 77 77 77 77 77 77 67 67 67 67 67 67 67 67 67 67 67
#&gt; [865] 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67
#&gt; [889] 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 88 88 88 88 88 88 88 88
#&gt; [913] 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88
#&gt; [937] 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 70 70 70 70 70
#&gt; [961] 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
#&gt; [985] 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 69 69 69
#&gt; [1009] 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69
#&gt; [1033] 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 71 71
#&gt; [1057] 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71
#&gt; [1081] 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 72 72 72
#&gt; [1105] 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72
#&gt; [1129] 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 65 65 65 65 65 65
#&gt; [1153] 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65
#&gt; [1177] 65 65 65 65 65 65 65 65 65 65 65 65 65 66 66 66 66 66 66 66 66 66 66 66
#&gt; [1201] 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66
#&gt; [1225] 66 66 66 66 66 66 66 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
#&gt; [1249] 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
#&gt; [1273] 85 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68
#&gt; [1297] 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 47 47 47 47 47 47
#&gt; [1321] 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47
#&gt; [1345] 47 47 47 47 47 47 47 47 47 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90
#&gt; [1369] 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 89 89 89 89
#&gt; [1393] 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
#&gt; [1417] 89 89 89 89 89 89 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84
#&gt; [1441] 84 84 84 84 84 84 84 84 84 84 84 84 84 84 84 62 62 62 62 62 62 62 62 62
#&gt; [1465] 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 59
#&gt; [1489] 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59
#&gt; [1513] 59 59 59 59 59 59 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
#&gt; [1537] 64 64 64 64 64 64 64 64 64 64 64 64 64 57 57 57 57 57 57 57 57 57 57 57
#&gt; [1561] 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 63 63 63 63 63 63
#&gt; [1585] 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 51 51
#&gt; [1609] 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51
#&gt; [1633] 51 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52
#&gt; [1657] 52 52 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60
#&gt; [1681] 60 60 60 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53
#&gt; [1705] 53 53 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
#&gt; [1729] 58 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 56
#&gt; [1753] 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 45 45 45 45
#&gt; [1777] 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 55 55 55 55 55 55 55 55
#&gt; [1801] 55 55 55 55 55 55 55 55 55 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
#&gt; [1825] 61 61 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 43 43 43 43 43 43
#&gt; [1849] 43 43 43 43 43 43 43 43 43 44 44 44 44 44 44 44 44 44 44 44 44 44 46 46
#&gt; [1873] 46 46 46 46 46 46 46 46 46 46 46 41 41 41 41 41 41 41 41 41 41 48 48 48
#&gt; [1897] 48 48 48 48 48 48 48 30 30 30 30 30 30 30 30 30 54 54 54 54 54 54 54 54
#&gt; [1921] 54 92 92 92 92 92 92 92 92 92 91 91 91 91 91 91 91 91 42 42 42 42 42 42
#&gt; [1945] 42 38 38 38 38 38 38 94 94 94 94 94 94 20 20 20 20 39 39 39 39 49 49 49
#&gt; [1969] 49 19 19 19 29 29 29 33 33 33 37 37 37 40 40 40 18 18 24 24 31 31 36 36
#&gt; [1993] 97 97 14 22 32 34 35 95</div><div class='input'>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/identical'>identical</a></span>(<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/identical'>identical</a></span>(<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>age</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/vector'>as.vector</a></span>() <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/vector'>as.vector</a></span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sort'>sort</a></span>(), <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sort'>sort</a></span>(),
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sort'>sort</a></span>(<span class='no'>septic_patients</span>$<span class='no'>age</span>)) <span class='co'># TRUE</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sort'>sort</a></span>(<span class='no'>septic_patients</span>$<span class='no'>age</span>)) <span class='co'># TRUE</span></div><div class='output co'>#&gt; [1] TRUE</div><div class='input'>
<span class='co'># it also supports `table` objects</span> <span class='co'># it also supports `table` objects</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/table'>table</a></span>(<span class='no'>septic_patients</span>$<span class='no'>gender</span>, <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/table'>table</a></span>(<span class='no'>septic_patients</span>$<span class='no'>gender</span>,
<span class='no'>septic_patients</span>$<span class='no'>age</span>) <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span>$<span class='no'>age</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='kw'>sep</span> <span class='kw'>=</span> <span class='st'>" **sep** "</span>) <span class='fu'>freq</span>(<span class='kw'>sep</span> <span class='kw'>=</span> <span class='st'>" **sep** "</span>)</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table of a `table` object**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:---|:------------|-----:|-------:|----------:|------------:|
#&gt; |1 |F **sep** 83 | 55| 2.8%| 55| 2.8%|
#&gt; |2 |M **sep** 78 | 51| 2.6%| 106| 5.3%|
#&gt; |3 |M **sep** 83 | 47| 2.4%| 153| 7.7%|
#&gt; |4 |M **sep** 82 | 43| 2.2%| 196| 9.8%|
#&gt; |5 |M **sep** 79 | 42| 2.1%| 238| 11.9%|
#&gt; |6 |F **sep** 80 | 41| 2.1%| 279| 14.0%|
#&gt; |7 |F **sep** 76 | 39| 2.0%| 318| 15.9%|
#&gt; |8 |F **sep** 75 | 38| 1.9%| 356| 17.8%|
#&gt; |9 |F **sep** 86 | 38| 1.9%| 394| 19.7%|
#&gt; |10 |M **sep** 71 | 35| 1.8%| 429| 21.5%|
#&gt; |11 |M **sep** 75 | 34| 1.7%| 463| 23.2%|
#&gt; |12 |M **sep** 77 | 34| 1.7%| 497| 24.9%|
#&gt; |13 |M **sep** 80 | 34| 1.7%| 531| 26.6%|
#&gt; |14 |F **sep** 81 | 33| 1.7%| 564| 28.2%|
#&gt; |15 |M **sep** 88 | 31| 1.6%| 595| 29.8%|
#&gt; |16 |F **sep** 79 | 30| 1.5%| 625| 31.3%|
#&gt; |17 |M **sep** 74 | 30| 1.5%| 655| 32.8%|
#&gt; |18 |M **sep** 87 | 30| 1.5%| 685| 34.3%|
#&gt; |19 |F **sep** 65 | 29| 1.5%| 714| 35.7%|
#&gt; |20 |M **sep** 73 | 29| 1.5%| 743| 37.2%|
#&gt; |21 |M **sep** 69 | 28| 1.4%| 771| 38.6%|
#&gt; |22 |M **sep** 72 | 28| 1.4%| 799| 40.0%|
#&gt; |23 |F **sep** 67 | 27| 1.4%| 826| 41.3%|
#&gt; |24 |F **sep** 87 | 27| 1.4%| 853| 42.7%|
#&gt; |25 |M **sep** 76 | 26| 1.3%| 879| 44.0%|
#&gt; |26 |F **sep** 66 | 25| 1.3%| 904| 45.2%|
#&gt; |27 |F **sep** 70 | 25| 1.3%| 929| 46.5%|
#&gt; |28 |M **sep** 70 | 25| 1.3%| 954| 47.7%|
#&gt; |29 |M **sep** 81 | 25| 1.3%| 979| 49.0%|
#&gt; |30 |F **sep** 47 | 24| 1.2%| 1,003| 50.1%|
#&gt; |31 |F **sep** 73 | 24| 1.2%| 1,027| 51.4%|
#&gt; |32 |F **sep** 74 | 24| 1.2%| 1,051| 52.6%|
#&gt; |33 |M **sep** 67 | 24| 1.2%| 1,075| 53.8%|
#&gt; |34 |M **sep** 86 | 23| 1.2%| 1,098| 54.9%|
#&gt; |35 |F **sep** 89 | 22| 1.1%| 1,120| 56.0%|
#&gt; |36 |M **sep** 68 | 22| 1.1%| 1,142| 57.1%|
#&gt; |37 |M **sep** 85 | 22| 1.1%| 1,164| 58.2%|
#&gt; |38 |F **sep** 69 | 21| 1.1%| 1,185| 59.3%|
#&gt; |39 |M **sep** 62 | 21| 1.1%| 1,206| 60.3%|
#&gt; |40 |F **sep** 85 | 20| 1.0%| 1,226| 61.3%|
#&gt; |41 |F **sep** 88 | 20| 1.0%| 1,246| 62.3%|
#&gt; |42 |F **sep** 90 | 20| 1.0%| 1,266| 63.3%|
#&gt; |43 |M **sep** 64 | 20| 1.0%| 1,286| 64.3%|
#&gt; |44 |F **sep** 68 | 19| 1.0%| 1,305| 65.3%|
#&gt; |45 |F **sep** 78 | 19| 1.0%| 1,324| 66.2%|
#&gt; |46 |F **sep** 82 | 19| 1.0%| 1,343| 67.2%|
#&gt; |47 |F **sep** 45 | 18| 0.9%| 1,361| 68.1%|
#&gt; |48 |F **sep** 60 | 18| 0.9%| 1,379| 69.0%|
#&gt; |49 |F **sep** 77 | 18| 0.9%| 1,397| 69.9%|
#&gt; |50 |F **sep** 84 | 18| 0.9%| 1,415| 70.8%|
#&gt; |51 |M **sep** 51 | 18| 0.9%| 1,433| 71.7%|
#&gt; |52 |M **sep** 52 | 18| 0.9%| 1,451| 72.6%|
#&gt; |53 |F **sep** 57 | 17| 0.9%| 1,468| 73.4%|
#&gt; |54 |F **sep** 72 | 17| 0.9%| 1,485| 74.3%|
#&gt; |55 |M **sep** 66 | 17| 0.9%| 1,502| 75.1%|
#&gt; |56 |F **sep** 58 | 16| 0.8%| 1,518| 75.9%|
#&gt; |57 |F **sep** 59 | 16| 0.8%| 1,534| 76.7%|
#&gt; |58 |M **sep** 56 | 16| 0.8%| 1,550| 77.5%|
#&gt; |59 |M **sep** 47 | 15| 0.8%| 1,565| 78.3%|
#&gt; |60 |M **sep** 59 | 15| 0.8%| 1,580| 79.0%|
#&gt; |61 |M **sep** 84 | 15| 0.8%| 1,595| 79.8%|
#&gt; |62 |M **sep** 90 | 15| 0.8%| 1,610| 80.5%|
#&gt; |63 |F **sep** 63 | 14| 0.7%| 1,624| 81.2%|
#&gt; |64 |M **sep** 53 | 14| 0.7%| 1,638| 81.9%|
#&gt; |65 |M **sep** 63 | 14| 0.7%| 1,652| 82.6%|
#&gt; |66 |M **sep** 65 | 14| 0.7%| 1,666| 83.3%|
#&gt; |67 |M **sep** 61 | 13| 0.7%| 1,679| 84.0%|
#&gt; |68 |F **sep** 50 | 12| 0.6%| 1,691| 84.6%|
#&gt; |69 |F **sep** 71 | 12| 0.6%| 1,703| 85.2%|
#&gt; |70 |M **sep** 57 | 12| 0.6%| 1,715| 85.8%|
#&gt; |71 |M **sep** 89 | 12| 0.6%| 1,727| 86.4%|
#&gt; |72 |M **sep** 93 | 12| 0.6%| 1,739| 87.0%|
#&gt; |73 |F **sep** 62 | 11| 0.6%| 1,750| 87.5%|
#&gt; |74 |F **sep** 64 | 11| 0.6%| 1,761| 88.1%|
#&gt; |75 |M **sep** 50 | 10| 0.5%| 1,771| 88.6%|
#&gt; |76 |F **sep** 43 | 9| 0.5%| 1,780| 89.0%|
#&gt; |77 |F **sep** 46 | 9| 0.5%| 1,789| 89.5%|
#&gt; |78 |F **sep** 51 | 9| 0.5%| 1,798| 89.9%|
#&gt; |79 |F **sep** 53 | 9| 0.5%| 1,807| 90.4%|
#&gt; |80 |F **sep** 55 | 9| 0.5%| 1,816| 90.8%|
#&gt; |81 |M **sep** 30 | 9| 0.5%| 1,825| 91.3%|
#&gt; |82 |F **sep** 44 | 8| 0.4%| 1,833| 91.7%|
#&gt; |83 |M **sep** 55 | 8| 0.4%| 1,841| 92.1%|
#&gt; |84 |F **sep** 41 | 7| 0.4%| 1,848| 92.4%|
#&gt; |85 |F **sep** 48 | 7| 0.4%| 1,855| 92.8%|
#&gt; |86 |F **sep** 52 | 7| 0.4%| 1,862| 93.1%|
#&gt; |87 |M **sep** 58 | 7| 0.4%| 1,869| 93.5%|
#&gt; |88 |M **sep** 60 | 7| 0.4%| 1,876| 93.8%|
#&gt; |89 |F **sep** 92 | 6| 0.3%| 1,882| 94.1%|
#&gt; |90 |M **sep** 43 | 6| 0.3%| 1,888| 94.4%|
#&gt; |91 |F **sep** 38 | 5| 0.3%| 1,893| 94.7%|
#&gt; |92 |F **sep** 42 | 5| 0.3%| 1,898| 94.9%|
#&gt; |93 |F **sep** 56 | 5| 0.3%| 1,903| 95.2%|
#&gt; |94 |M **sep** 44 | 5| 0.3%| 1,908| 95.4%|
#&gt; |95 |M **sep** 54 | 5| 0.3%| 1,913| 95.7%|
#&gt; |96 |F **sep** 20 | 4| 0.2%| 1,917| 95.9%|
#&gt; |97 |F **sep** 54 | 4| 0.2%| 1,921| 96.1%|
#&gt; |98 |F **sep** 61 | 4| 0.2%| 1,925| 96.3%|
#&gt; |99 |F **sep** 91 | 4| 0.2%| 1,929| 96.5%|
#&gt; |100 |F **sep** 93 | 4| 0.2%| 1,933| 96.7%|
#&gt; |101 |F **sep** 94 | 4| 0.2%| 1,937| 96.9%|
#&gt; |102 |M **sep** 46 | 4| 0.2%| 1,941| 97.1%|
#&gt; |103 |M **sep** 91 | 4| 0.2%| 1,945| 97.3%|
#&gt; |104 |F **sep** 39 | 3| 0.2%| 1,948| 97.4%|
#&gt; |105 |M **sep** 19 | 3| 0.2%| 1,951| 97.6%|
#&gt; |106 |M **sep** 33 | 3| 0.2%| 1,954| 97.7%|
#&gt; |107 |M **sep** 41 | 3| 0.2%| 1,957| 97.9%|
#&gt; |108 |M **sep** 48 | 3| 0.2%| 1,960| 98.0%|
#&gt; |109 |M **sep** 92 | 3| 0.2%| 1,963| 98.2%|
#&gt; |110 |F **sep** 31 | 2| 0.1%| 1,965| 98.3%|
#&gt; |111 |F **sep** 49 | 2| 0.1%| 1,967| 98.4%|
#&gt; |112 |M **sep** 18 | 2| 0.1%| 1,969| 98.5%|
#&gt; |113 |M **sep** 24 | 2| 0.1%| 1,971| 98.6%|
#&gt; |114 |M **sep** 29 | 2| 0.1%| 1,973| 98.7%|
#&gt; |115 |M **sep** 36 | 2| 0.1%| 1,975| 98.8%|
#&gt; |116 |M **sep** 37 | 2| 0.1%| 1,977| 98.9%|
#&gt; |117 |M **sep** 40 | 2| 0.1%| 1,979| 99.0%|
#&gt; |118 |M **sep** 42 | 2| 0.1%| 1,981| 99.1%|
#&gt; |119 |M **sep** 45 | 2| 0.1%| 1,983| 99.2%|
#&gt; |120 |M **sep** 49 | 2| 0.1%| 1,985| 99.3%|
#&gt; |121 |M **sep** 94 | 2| 0.1%| 1,987| 99.4%|
#&gt; |122 |M **sep** 97 | 2| 0.1%| 1,989| 99.5%|
#&gt; |123 |F **sep** 22 | 1| 0.1%| 1,990| 99.5%|
#&gt; |124 |F **sep** 29 | 1| 0.1%| 1,991| 99.6%|
#&gt; |125 |F **sep** 34 | 1| 0.1%| 1,992| 99.6%|
#&gt; |126 |F **sep** 35 | 1| 0.1%| 1,993| 99.7%|
#&gt; |127 |F **sep** 37 | 1| 0.1%| 1,994| 99.7%|
#&gt; |128 |F **sep** 40 | 1| 0.1%| 1,995| 99.8%|
#&gt; |129 |M **sep** 14 | 1| 0.1%| 1,996| 99.8%|
#&gt; |130 |M **sep** 32 | 1| 0.1%| 1,997| 99.9%|
#&gt; |131 |M **sep** 38 | 1| 0.1%| 1,998| 99.9%|
#&gt; |132 |M **sep** 39 | 1| 0.1%| 1,999| 100.0%|
#&gt; |133 |M **sep** 95 | 1| 0.1%| 2,000| 100.0%|
#&gt;
#&gt; </div><div class='input'>
<span class='co'># only get selected columns</span> <span class='co'># only get selected columns</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>item</span>, <span class='no'>percent</span>) <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>item</span>, <span class='no'>percent</span>)</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table of `hospital_id`**
#&gt;
#&gt;
#&gt; | |Item | Percent|
#&gt; |:--|:----|-------:|
#&gt; |1 |D | 38.1%|
#&gt; |2 |B | 33.2%|
#&gt; |3 |A | 16.1%|
#&gt; |4 |C | 12.7%|
#&gt;
#&gt; </div><div class='input'>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'>freq</span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(-<span class='no'>count</span>, -<span class='no'>cum_count</span>) <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(-<span class='no'>count</span>, -<span class='no'>cum_count</span>)</div><div class='output co'>#&gt;
#&gt;
#&gt; **Frequency table of `hospital_id`**
#&gt;
#&gt;
#&gt; | |Item | Percent| Cum. Percent|
#&gt; |:--|:----|-------:|------------:|
#&gt; |1 |D | 38.1%| 38.1%|
#&gt; |2 |B | 33.2%| 71.3%|
#&gt; |3 |A | 16.1%| 87.3%|
#&gt; |4 |C | 12.7%| 100.0%|
#&gt;
#&gt; </div><div class='input'>
<span class='co'># check differences between frequency tables</span> <span class='co'># check differences between frequency tables</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/diff'>diff</a></span>(<span class='fu'>freq</span>(<span class='no'>septic_patients</span>$<span class='no'>trim</span>), <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/diff'>diff</a></span>(<span class='fu'>freq</span>(<span class='no'>septic_patients</span>$<span class='no'>trim</span>),
<span class='fu'>freq</span>(<span class='no'>septic_patients</span>$<span class='no'>trsu</span>)) <span class='fu'>freq</span>(<span class='no'>septic_patients</span>$<span class='no'>trsu</span>))</div><div class='output co'>#&gt; Differences between frequency tables
<span class='co'># }</span></pre> #&gt;
#&gt; |Item | Count #1| Count #2| Difference| Diff. percent|
#&gt; |:----|--------:|--------:|----------:|-------------:|
#&gt; |S | 918| 1392| +474| +51.6%|
#&gt; |R | 571| 361| -210| -36.8%|
#&gt; |I | 10| 6| -4| -40.0%|</div></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -270,8 +270,7 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># = EXAMPLE 1 =</span>
<span class='co'># = EXAMPLE 1 =</span>
<span class='co'># Shivrain et al. (2006) crossed clearfield rice (which are resistant</span> <span class='co'># Shivrain et al. (2006) crossed clearfield rice (which are resistant</span>
<span class='co'># to the herbicide imazethapyr) with red rice (which are susceptible to</span> <span class='co'># to the herbicide imazethapyr) with red rice (which are susceptible to</span>
<span class='co'># imazethapyr). They then crossed the hybrid offspring and examined the</span> <span class='co'># imazethapyr). They then crossed the hybrid offspring and examined the</span>
@ -297,13 +296,17 @@
<span class='co'># observed 1752 right-billed and 1895 left-billed crossbills.</span> <span class='co'># observed 1752 right-billed and 1895 left-billed crossbills.</span>
<span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>1752</span>, <span class='fl'>1895</span>) <span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>1752</span>, <span class='fl'>1895</span>)
<span class='fu'>g.test</span>(<span class='no'>x</span>) <span class='fu'>g.test</span>(<span class='no'>x</span>)</div><div class='output co'>#&gt;
<span class='co'># p = 0.01787343</span> #&gt; G-test of goodness-of-fit (likelihood ratio test)
#&gt;
#&gt; data: x
#&gt; X-squared = 5.6085, df = 1, p-value = 0.01787
#&gt; </div><div class='input'># p = 0.01787343
<span class='co'># There is a significant difference from a 1:1 ratio.</span> # There is a significant difference from a 1:1 ratio.
<span class='co'># Meaning: there are significantly more left-billed birds.</span> # Meaning: there are significantly more left-billed birds.
<span class='co'># }</span></pre> </div></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -263,14 +263,12 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>ggplot2</span>) <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>ggplot2</span>)
<span class='co'># get antimicrobial results for drugs against a UTI:</span> <span class='co'># get antimicrobial results for drugs against a UTI:</span>
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>)) + <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>)) +
<span class='fu'>geom_rsi</span>() <span class='fu'>geom_rsi</span>()</div><div class='img'><img src='ggplot_rsi-1.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># prettify the plot using some additional functions:</span> <span class='co'># prettify the plot using some additional functions:</span>
<span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span>[, <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"amox"</span>, <span class='st'>"nitr"</span>, <span class='st'>"fosf"</span>, <span class='st'>"trim"</span>, <span class='st'>"cipr"</span>)] <span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span>[, <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"amox"</span>, <span class='st'>"nitr"</span>, <span class='st'>"fosf"</span>, <span class='st'>"trim"</span>, <span class='st'>"cipr"</span>)]
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>df</span>) + <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>df</span>) +
@ -278,18 +276,15 @@
<span class='fu'>scale_y_percent</span>() + <span class='fu'>scale_y_percent</span>() +
<span class='fu'>scale_rsi_colours</span>() + <span class='fu'>scale_rsi_colours</span>() +
<span class='fu'>labels_rsi_count</span>() + <span class='fu'>labels_rsi_count</span>() +
<span class='fu'>theme_rsi</span>() <span class='fu'>theme_rsi</span>()</div><div class='img'><img src='ggplot_rsi-2.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># or better yet, simplify this using the wrapper function - a single command:</span> <span class='co'># or better yet, simplify this using the wrapper function - a single command:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>() <span class='fu'>ggplot_rsi</span>()</div><div class='img'><img src='ggplot_rsi-3.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># get only portions and no counts:</span> <span class='co'># get only portions and no counts:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>fun</span> <span class='kw'>=</span> <span class='no'>portion_df</span>) <span class='fu'>ggplot_rsi</span>(<span class='kw'>fun</span> <span class='kw'>=</span> <span class='no'>portion_df</span>)</div><div class='img'><img src='ggplot_rsi-4.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># add other ggplot2 parameters as you like:</span> <span class='co'># add other ggplot2 parameters as you like:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
@ -297,8 +292,7 @@
<span class='kw'>colour</span> <span class='kw'>=</span> <span class='st'>"black"</span>, <span class='kw'>colour</span> <span class='kw'>=</span> <span class='st'>"black"</span>,
<span class='kw'>size</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>size</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>linetype</span> <span class='kw'>=</span> <span class='fl'>2</span>, <span class='kw'>linetype</span> <span class='kw'>=</span> <span class='fl'>2</span>,
<span class='kw'>alpha</span> <span class='kw'>=</span> <span class='fl'>0.25</span>) <span class='kw'>alpha</span> <span class='kw'>=</span> <span class='fl'>0.25</span>)</div><div class='img'><img src='ggplot_rsi-5.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># resistance of ciprofloxacine per age group</span> <span class='co'># resistance of ciprofloxacine per age group</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>first_isolate</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>.</span>)) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>first_isolate</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>.</span>)) <span class='kw'>%&gt;%</span>
@ -308,13 +302,12 @@
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>age_group</span> <span class='kw'>=</span> <span class='fu'><a href='age_groups.html'>age_groups</a></span>(<span class='no'>age</span>)) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>age_group</span> <span class='kw'>=</span> <span class='fu'><a href='age_groups.html'>age_groups</a></span>(<span class='no'>age</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>age_group</span>, <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>age_group</span>,
<span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"age_group"</span>) <span class='fu'>ggplot_rsi</span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"age_group"</span>)</div><div class='output co'>#&gt; <span class='message'><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>mo</span><span style='color: #0000BB;'>` as input for `col_mo`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>date</span><span style='color: #0000BB;'>` as input for `col_date`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>patient_id</span><span style='color: #0000BB;'>` as input for `col_patient_id`.</span><span></span></div><div class='output co'>#&gt; <span class='message'>=&gt; Found </span><span style='font-weight: bold;'>1,317 first isolates</span><span> (65.9% of total)</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Removed 3 rows containing missing values (geom_bar).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Removed 3 rows containing missing values (geom_text).</span></div><div class='img'><img src='ggplot_rsi-6.png' alt='' width='700' height='433' /></div></span><div class='input'>
<span class='co'># }</span><span class='co'># NOT RUN {</span>
<span class='co'># for colourblind mode, use divergent colours from the viridis package:</span> <span class='co'># for colourblind mode, use divergent colours from the viridis package:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>nitr</span>, <span class='no'>fosf</span>, <span class='no'>trim</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>() + <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_viridis.html'>scale_fill_viridis_d</a></span>() <span class='fu'>ggplot_rsi</span>() + <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_viridis.html'>scale_fill_viridis_d</a></span>()</div><div class='output co'>#&gt; <span class='message'>Scale for 'fill' is already present. Adding another scale for 'fill', which</span>
#&gt; <span class='message'>will replace the existing scale.</span></div><div class='img'><img src='ggplot_rsi-7.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='co'># it also supports groups (don't forget to use the group var on `x` or `facet`):</span> <span class='co'># it also supports groups (don't forget to use the group var on `x` or `facet`):</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
@ -324,8 +317,7 @@
<span class='kw'>facet</span> <span class='kw'>=</span> <span class='no'>Antibiotic</span>, <span class='kw'>facet</span> <span class='kw'>=</span> <span class='no'>Antibiotic</span>,
<span class='kw'>nrow</span> <span class='kw'>=</span> <span class='fl'>1</span>) + <span class='kw'>nrow</span> <span class='kw'>=</span> <span class='fl'>1</span>) +
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/labs.html'>labs</a></span>(<span class='kw'>title</span> <span class='kw'>=</span> <span class='st'>"AMR of Anti-UTI Drugs Per Hospital"</span>, <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/labs.html'>labs</a></span>(<span class='kw'>title</span> <span class='kw'>=</span> <span class='st'>"AMR of Anti-UTI Drugs Per Hospital"</span>,
<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"Hospital"</span>) <span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"Hospital"</span>)</div><div class='output co'>#&gt; <span class='error'>Error in ggplot_rsi(., x = hospital_id, facet = Antibiotic, nrow = 1): object 'hospital_id' not found</span></div><div class='input'>
<span class='co'># genuine analysis: check 2 most prevalent microorganisms</span> <span class='co'># genuine analysis: check 2 most prevalent microorganisms</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='co'># create new bacterial ID's, with all CoNS under the same group (Becker et al.)</span> <span class='co'># create new bacterial ID's, with all CoNS under the same group (Becker et al.)</span>
@ -352,8 +344,7 @@
<span class='kw'>nrow</span> <span class='kw'>=</span> <span class='fl'>1</span>) + <span class='kw'>nrow</span> <span class='kw'>=</span> <span class='fl'>1</span>) +
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/labs.html'>labs</a></span>(<span class='kw'>title</span> <span class='kw'>=</span> <span class='st'>"AMR of Top Three Microorganisms In Blood Culture Isolates"</span>, <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/labs.html'>labs</a></span>(<span class='kw'>title</span> <span class='kw'>=</span> <span class='st'>"AMR of Top Three Microorganisms In Blood Culture Isolates"</span>,
<span class='kw'>subtitle</span> <span class='kw'>=</span> <span class='st'>"Only First Isolates, CoNS grouped according to Becker et al. (2014)"</span>, <span class='kw'>subtitle</span> <span class='kw'>=</span> <span class='st'>"Only First Isolates, CoNS grouped according to Becker et al. (2014)"</span>,
<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"Microorganisms"</span>) <span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"Microorganisms"</span>)</div><div class='output co'>#&gt; <span class='message'>=&gt; Found <span style='font-weight: bold;'>782 first isolates</span><span> (59.9% of total)</span></div><div class='output co'>#&gt; <span class='error'>Error in ggplot_rsi(., x = Antibiotic, facet = mo, translate_ab = FALSE, nrow = 1): object 'Antibiotic' not found</span></div></span></pre>
<span class='co'># }</span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

File diff suppressed because it is too large Load Diff

View File

@ -255,10 +255,8 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># septic_patients is a dataset available in the AMR package</span>
<span class='co'># septic_patients is a dataset available in the AMR package</span> ?<span class='no'>septic_patients</span></div><div class='output co'>#&gt; <span class='message'>Rendering development documentation for 'septic_patients'</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
?<span class='no'>septic_patients</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='co'># set key antibiotics to a new variable</span> <span class='co'># set key antibiotics to a new variable</span>
<span class='no'>my_patients</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>my_patients</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>keyab</span> <span class='kw'>=</span> <span class='fu'>key_antibiotics</span>(<span class='no'>.</span>)) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>keyab</span> <span class='kw'>=</span> <span class='fu'>key_antibiotics</span>(<span class='no'>.</span>)) <span class='kw'>%&gt;%</span>
@ -267,23 +265,18 @@
<span class='kw'>first_regular</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>.</span>, <span class='kw'>col_keyantibiotics</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>), <span class='kw'>first_regular</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>.</span>, <span class='kw'>col_keyantibiotics</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>),
<span class='co'># and first WEIGHTED isolates</span> <span class='co'># and first WEIGHTED isolates</span>
<span class='kw'>first_weighted</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>.</span>, <span class='kw'>col_keyantibiotics</span> <span class='kw'>=</span> <span class='st'>"keyab"</span>) <span class='kw'>first_weighted</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>.</span>, <span class='kw'>col_keyantibiotics</span> <span class='kw'>=</span> <span class='st'>"keyab"</span>)
) )</div><div class='output co'>#&gt; <span class='message'><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>mo</span><span style='color: #0000BB;'>` as input for `col_mo`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>mo</span><span style='color: #0000BB;'>` as input for `col_mo`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>date</span><span style='color: #0000BB;'>` as input for `col_date`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>patient_id</span><span style='color: #0000BB;'>` as input for `col_patient_id`.</span><span></span></div><div class='output co'>#&gt; <span class='message'>=&gt; Found </span><span style='font-weight: bold;'>1,317 first isolates</span><span> (65.9% of total)</span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>mo</span><span style='color: #0000BB;'>` as input for `col_mo`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>date</span><span style='color: #0000BB;'>` as input for `col_date`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>patient_id</span><span style='color: #0000BB;'>` as input for `col_patient_id`.</span><span></span></div><div class='output co'>#&gt; [Criterion] Inclusion based on key antibiotics, ignoring I.</div><div class='output co'>#&gt; <span class='message'>=&gt; Found </span><span style='font-weight: bold;'>1,413 first weighted isolates</span><span> (70.7% of total)</span></div><div class='input'>
<span class='co'># Check the difference, in this data set it results in 7% more isolates:</span> <span class='co'># Check the difference, in this data set it results in 7% more isolates:</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sum'>sum</a></span>(<span class='no'>my_patients</span>$<span class='no'>first_regular</span>, <span class='kw'>na.rm</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sum'>sum</a></span>(<span class='no'>my_patients</span>$<span class='no'>first_regular</span>, <span class='kw'>na.rm</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#&gt; [1] 1317</div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sum'>sum</a></span>(<span class='no'>my_patients</span>$<span class='no'>first_weighted</span>, <span class='kw'>na.rm</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#&gt; [1] 1413</div><div class='input'>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sum'>sum</a></span>(<span class='no'>my_patients</span>$<span class='no'>first_weighted</span>, <span class='kw'>na.rm</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
<span class='co'># output of the `key_antibiotics` function could be like this:</span> <span class='co'># output of the `key_antibiotics` function could be like this:</span>
<span class='no'>strainA</span> <span class='kw'>&lt;-</span> <span class='st'>"SSSRR.S.R..S"</span> <span class='no'>strainA</span> <span class='kw'>&lt;-</span> <span class='st'>"SSSRR.S.R..S"</span>
<span class='no'>strainB</span> <span class='kw'>&lt;-</span> <span class='st'>"SSSIRSSSRSSS"</span> <span class='no'>strainB</span> <span class='kw'>&lt;-</span> <span class='st'>"SSSIRSSSRSSS"</span>
<span class='fu'>key_antibiotics_equal</span>(<span class='no'>strainA</span>, <span class='no'>strainB</span>) <span class='fu'>key_antibiotics_equal</span>(<span class='no'>strainA</span>, <span class='no'>strainB</span>)</div><div class='output co'>#&gt; [1] TRUE</div><div class='input'><span class='co'># TRUE, because I is ignored (as well as missing values)</span>
<span class='co'># TRUE, because I is ignored (as well as missing values)</span>
<span class='fu'>key_antibiotics_equal</span>(<span class='no'>strainA</span>, <span class='no'>strainB</span>, <span class='kw'>ignore_I</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>) <span class='fu'>key_antibiotics_equal</span>(<span class='no'>strainA</span>, <span class='no'>strainB</span>, <span class='kw'>ignore_I</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</div><div class='output co'>#&gt; [1] FALSE</div><div class='input'># FALSE, because I is not ignored and so the 4th value differs
<span class='co'># FALSE, because I is not ignored and so the 4th value differs</span> </div></span></pre>
<span class='co'># }</span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -210,28 +210,38 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># simple test</span>
<span class='co'># simple test</span>
<span class='no'>a</span> <span class='kw'>&lt;-</span> <span class='st'>"This is a test"</span> <span class='no'>a</span> <span class='kw'>&lt;-</span> <span class='st'>"This is a test"</span>
<span class='no'>b</span> <span class='kw'>&lt;-</span> <span class='st'>"TEST"</span> <span class='no'>b</span> <span class='kw'>&lt;-</span> <span class='st'>"TEST"</span>
<span class='no'>a</span> <span class='kw'>%like%</span> <span class='no'>b</span> <span class='no'>a</span> <span class='kw'>%like%</span> <span class='no'>b</span></div><div class='output co'>#&gt; [1] TRUE</div><div class='input'><span class='co'>#&gt; TRUE</span>
<span class='co'>#&gt; TRUE</span> <span class='no'>b</span> <span class='kw'>%like%</span> <span class='no'>a</span></div><div class='output co'>#&gt; [1] FALSE</div><div class='input'><span class='co'>#&gt; FALSE</span>
<span class='no'>b</span> <span class='kw'>%like%</span> <span class='no'>a</span>
<span class='co'>#&gt; FALSE</span>
<span class='co'># also supports multiple patterns, length must be equal to x</span> <span class='co'># also supports multiple patterns, length must be equal to x</span>
<span class='no'>a</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"Test case"</span>, <span class='st'>"Something different"</span>, <span class='st'>"Yet another thing"</span>) <span class='no'>a</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"Test case"</span>, <span class='st'>"Something different"</span>, <span class='st'>"Yet another thing"</span>)
<span class='no'>b</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"case"</span>, <span class='st'>"diff"</span>, <span class='st'>"yet"</span>) <span class='no'>b</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"case"</span>, <span class='st'>"diff"</span>, <span class='st'>"yet"</span>)
<span class='no'>a</span> <span class='kw'>%like%</span> <span class='no'>b</span> <span class='no'>a</span> <span class='kw'>%like%</span> <span class='no'>b</span></div><div class='output co'>#&gt; [1] TRUE TRUE TRUE</div><div class='input'><span class='co'>#&gt; TRUE TRUE TRUE</span>
<span class='co'>#&gt; TRUE TRUE TRUE</span>
<span class='co'># get frequencies of bacteria whose name start with 'Ent' or 'ent'</span> <span class='co'># get frequencies of bacteria whose name start with 'Ent' or 'ent'</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>) <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='join.html'>left_join_microorganisms</a></span>() <span class='kw'>%&gt;%</span> <span class='fu'><a href='join.html'>left_join_microorganisms</a></span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>genus</span> <span class='kw'>%like%</span> <span class='st'>'^ent'</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>genus</span> <span class='kw'>%like%</span> <span class='st'>'^ent'</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='freq.html'>freq</a></span>(<span class='no'>genus</span>, <span class='no'>species</span>) <span class='fu'><a href='freq.html'>freq</a></span>(<span class='no'>genus</span>, <span class='no'>species</span>)</div><div class='output co'>#&gt; <span class='message'>Joining, by = "mo"</span></div><div class='output co'>#&gt;
<span class='co'># }</span></pre> #&gt;
#&gt; **Frequency table of `genus` and `species`**
#&gt;
#&gt;
#&gt; | |Item | Count| Percent| Cum. Count| Cum. Percent|
#&gt; |:--|:--------------------------|-----:|-------:|----------:|------------:|
#&gt; |1 |Enterococcus faecalis | 39| 35.8%| 39| 35.8%|
#&gt; |2 |Enterobacter cloacae | 23| 21.1%| 62| 56.9%|
#&gt; |3 |Enterococcus faecium | 21| 19.3%| 83| 76.1%|
#&gt; |4 |Enterococcus species | 20| 18.3%| 103| 94.5%|
#&gt; |5 |Enterobacter aerogenes | 3| 2.8%| 106| 97.2%|
#&gt; |6 |Enterococcus avium | 2| 1.8%| 108| 99.1%|
#&gt; |7 |Enterococcus casseliflavus | 1| 0.9%| 109| 100.0%|
#&gt;
#&gt; </div></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

File diff suppressed because it is too large Load Diff

View File

@ -270,87 +270,67 @@ This package contains the <strong>complete microbial taxonomic data</strong> (wi
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># All properties of Escherichia coli</span>
<span class='co'># All properties of Escherichia coli</span>
<span class='co'>## taxonomic properties</span> <span class='co'>## taxonomic properties</span>
<span class='fu'>mo_kingdom</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bacteria"</span> <span class='fu'>mo_kingdom</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bacteria"</span></div><div class='output co'>#&gt; [1] "Bacteria"</div><div class='input'><span class='fu'>mo_subkingdom</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Negibacteria"</span></div><div class='output co'>#&gt; [1] "Negibacteria"</div><div class='input'><span class='fu'>mo_phylum</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Proteobacteria"</span></div><div class='output co'>#&gt; [1] "Proteobacteria"</div><div class='input'><span class='fu'>mo_class</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Gammaproteobacteria"</span></div><div class='output co'>#&gt; [1] "Gammaproteobacteria"</div><div class='input'><span class='fu'>mo_order</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Enterobacteriales"</span></div><div class='output co'>#&gt; [1] "Enterobacteriales"</div><div class='input'><span class='fu'>mo_family</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Enterobacteriaceae"</span></div><div class='output co'>#&gt; [1] "Enterobacteriaceae"</div><div class='input'><span class='fu'>mo_genus</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Escherichia"</span></div><div class='output co'>#&gt; [1] "Escherichia"</div><div class='input'><span class='fu'>mo_species</span>(<span class='st'>"E. coli"</span>) <span class='co'># "coli"</span></div><div class='output co'>#&gt; [1] "coli"</div><div class='input'><span class='fu'>mo_subspecies</span>(<span class='st'>"E. coli"</span>) <span class='co'># NA</span></div><div class='output co'>#&gt; [1] NA</div><div class='input'><span class='fu'>mo_TSN</span>(<span class='st'>"E. coli"</span>) <span class='co'># 285 (Taxonomic Serial Number)</span></div><div class='output co'>#&gt; [1] 285</div><div class='input'>
<span class='fu'>mo_subkingdom</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Negibacteria"</span>
<span class='fu'>mo_phylum</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Proteobacteria"</span>
<span class='fu'>mo_class</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Gammaproteobacteria"</span>
<span class='fu'>mo_order</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Enterobacteriales"</span>
<span class='fu'>mo_family</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Enterobacteriaceae"</span>
<span class='fu'>mo_genus</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Escherichia"</span>
<span class='fu'>mo_species</span>(<span class='st'>"E. coli"</span>) <span class='co'># "coli"</span>
<span class='fu'>mo_subspecies</span>(<span class='st'>"E. coli"</span>) <span class='co'># NA</span>
<span class='fu'>mo_TSN</span>(<span class='st'>"E. coli"</span>) <span class='co'># 285 (Taxonomic Serial Number)</span>
<span class='co'>## colloquial properties</span> <span class='co'>## colloquial properties</span>
<span class='fu'>mo_fullname</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Escherichia coli"</span> <span class='fu'>mo_fullname</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Escherichia coli"</span></div><div class='output co'>#&gt; [1] "Escherichia coli"</div><div class='input'><span class='fu'>mo_shortname</span>(<span class='st'>"E. coli"</span>) <span class='co'># "E. coli"</span></div><div class='output co'>#&gt; [1] "E. coli"</div><div class='input'>
<span class='fu'>mo_shortname</span>(<span class='st'>"E. coli"</span>) <span class='co'># "E. coli"</span>
<span class='co'>## other properties</span> <span class='co'>## other properties</span>
<span class='fu'>mo_gramstain</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Gram negative"</span> <span class='fu'>mo_gramstain</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Gram negative"</span></div><div class='output co'>#&gt; [1] "Gram-negatief"</div><div class='input'><span class='fu'>mo_type</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bacteria" (equal to kingdom)</span></div><div class='output co'>#&gt; [1] "Bacteriën"</div><div class='input'>
<span class='fu'>mo_type</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bacteria" (equal to kingdom)</span>
<span class='co'>## scientific reference</span> <span class='co'>## scientific reference</span>
<span class='fu'>mo_ref</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Castellani and Chalmers, 1919"</span> <span class='fu'>mo_ref</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Castellani and Chalmers, 1919"</span></div><div class='output co'>#&gt; [1] "Castellani and Chalmers, 1919"</div><div class='input'><span class='fu'>mo_authors</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Castellani and Chalmers"</span></div><div class='output co'>#&gt; [1] "Castellani and Chalmers"</div><div class='input'><span class='fu'>mo_year</span>(<span class='st'>"E. coli"</span>) <span class='co'># 1919</span></div><div class='output co'>#&gt; [1] 1919</div><div class='input'>
<span class='fu'>mo_authors</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Castellani and Chalmers"</span>
<span class='fu'>mo_year</span>(<span class='st'>"E. coli"</span>) <span class='co'># 1919</span>
<span class='co'># Abbreviations known in the field</span> <span class='co'># Abbreviations known in the field</span>
<span class='fu'>mo_genus</span>(<span class='st'>"MRSA"</span>) <span class='co'># "Staphylococcus"</span> <span class='fu'>mo_genus</span>(<span class='st'>"MRSA"</span>) <span class='co'># "Staphylococcus"</span></div><div class='output co'>#&gt; [1] "Staphylococcus"</div><div class='input'><span class='fu'>mo_species</span>(<span class='st'>"MRSA"</span>) <span class='co'># "aureus"</span></div><div class='output co'>#&gt; [1] "aureus"</div><div class='input'><span class='fu'>mo_shortname</span>(<span class='st'>"MRSA"</span>) <span class='co'># "S. aureus"</span></div><div class='output co'>#&gt; [1] "S. aureus"</div><div class='input'><span class='fu'>mo_gramstain</span>(<span class='st'>"MRSA"</span>) <span class='co'># "Gram positive"</span></div><div class='output co'>#&gt; [1] "Gram-positief"</div><div class='input'>
<span class='fu'>mo_species</span>(<span class='st'>"MRSA"</span>) <span class='co'># "aureus"</span> <span class='fu'>mo_genus</span>(<span class='st'>"VISA"</span>) <span class='co'># "Staphylococcus"</span></div><div class='output co'>#&gt; [1] "Staphylococcus"</div><div class='input'><span class='fu'>mo_species</span>(<span class='st'>"VISA"</span>) <span class='co'># "aureus"</span></div><div class='output co'>#&gt; [1] "aureus"</div><div class='input'>
<span class='fu'>mo_shortname</span>(<span class='st'>"MRSA"</span>) <span class='co'># "S. aureus"</span>
<span class='fu'>mo_gramstain</span>(<span class='st'>"MRSA"</span>) <span class='co'># "Gram positive"</span>
<span class='fu'>mo_genus</span>(<span class='st'>"VISA"</span>) <span class='co'># "Staphylococcus"</span>
<span class='fu'>mo_species</span>(<span class='st'>"VISA"</span>) <span class='co'># "aureus"</span>
<span class='co'># Known subspecies</span> <span class='co'># Known subspecies</span>
<span class='fu'>mo_genus</span>(<span class='st'>"doylei"</span>) <span class='co'># "Campylobacter"</span> <span class='fu'>mo_genus</span>(<span class='st'>"doylei"</span>) <span class='co'># "Campylobacter"</span></div><div class='output co'>#&gt; <span class='warning'>Warning: <span style='color: #BB0000;'>These 1 values could not be coerced to a valid MO code: "doylei". See mo_failures() to review them.</span><span></span></div><div class='output co'>#&gt; [1] NA</div><div class='input'><span class='fu'>mo_species</span>(<span class='st'>"doylei"</span>) <span class='co'># "jejuni"</span></div><div class='output co'>#&gt; <span class='warning'>Warning: </span><span style='color: #BB0000;'>These 1 values could not be coerced to a valid MO code: "doylei". See mo_failures() to review them.</span><span></span></div><div class='output co'>#&gt; [1] NA</div><div class='input'><span class='fu'>mo_fullname</span>(<span class='st'>"doylei"</span>) <span class='co'># "Campylobacter jejuni doylei"</span></div><div class='output co'>#&gt; <span class='warning'>Warning: </span><span style='color: #BB0000;'>These 1 values could not be coerced to a valid MO code: "doylei". See mo_failures() to review them.</span><span></span></div><div class='output co'>#&gt; [1] NA</div><div class='input'>
<span class='fu'>mo_species</span>(<span class='st'>"doylei"</span>) <span class='co'># "jejuni"</span> <span class='fu'>mo_fullname</span>(<span class='st'>"K. pneu rh"</span>) <span class='co'># "Klebsiella pneumoniae rhinoscleromatis"</span></div><div class='output co'>#&gt; [1] "Klebsiella pneumoniae rhinoscleromatis"</div><div class='input'><span class='fu'>mo_shortname</span>(<span class='st'>"K. pneu rh"</span>) <span class='co'># "K. pneumoniae"</span></div><div class='output co'>#&gt; [1] "K. pneumoniae"</div><div class='input'>
<span class='fu'>mo_fullname</span>(<span class='st'>"doylei"</span>) <span class='co'># "Campylobacter jejuni doylei"</span>
<span class='fu'>mo_fullname</span>(<span class='st'>"K. pneu rh"</span>) <span class='co'># "Klebsiella pneumoniae rhinoscleromatis"</span>
<span class='fu'>mo_shortname</span>(<span class='st'>"K. pneu rh"</span>) <span class='co'># "K. pneumoniae"</span>
<span class='co'># Becker classification, see ?as.mo</span> <span class='co'># Becker classification, see ?as.mo</span>
<span class='fu'>mo_fullname</span>(<span class='st'>"S. epi"</span>) <span class='co'># "Staphylococcus epidermidis"</span> <span class='fu'>mo_fullname</span>(<span class='st'>"S. epi"</span>) <span class='co'># "Staphylococcus epidermidis"</span></div><div class='output co'>#&gt; [1] "Staphylococcus epidermidis"</div><div class='input'><span class='fu'>mo_fullname</span>(<span class='st'>"S. epi"</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># "Coagulase Negative Staphylococcus (CoNS)"</span></div><div class='output co'>#&gt; [1] "Coagulase-negatieve Staphylococcus (CNS)"</div><div class='input'><span class='fu'>mo_shortname</span>(<span class='st'>"S. epi"</span>) <span class='co'># "S. epidermidis"</span></div><div class='output co'>#&gt; [1] "S. epidermidis"</div><div class='input'><span class='fu'>mo_shortname</span>(<span class='st'>"S. epi"</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># "CoNS"</span></div><div class='output co'>#&gt; [1] "CNS"</div><div class='input'>
<span class='fu'>mo_fullname</span>(<span class='st'>"S. epi"</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># "Coagulase Negative Staphylococcus (CoNS)"</span>
<span class='fu'>mo_shortname</span>(<span class='st'>"S. epi"</span>) <span class='co'># "S. epidermidis"</span>
<span class='fu'>mo_shortname</span>(<span class='st'>"S. epi"</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># "CoNS"</span>
<span class='co'># Lancefield classification, see ?as.mo</span> <span class='co'># Lancefield classification, see ?as.mo</span>
<span class='fu'>mo_fullname</span>(<span class='st'>"S. pyo"</span>) <span class='co'># "Streptococcus pyogenes"</span> <span class='fu'>mo_fullname</span>(<span class='st'>"S. pyo"</span>) <span class='co'># "Streptococcus pyogenes"</span></div><div class='output co'>#&gt; [1] "Streptococcus pyogenes"</div><div class='input'><span class='fu'>mo_fullname</span>(<span class='st'>"S. pyo"</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># "Streptococcus group A"</span></div><div class='output co'>#&gt; [1] "Streptococcus groep A"</div><div class='input'><span class='fu'>mo_shortname</span>(<span class='st'>"S. pyo"</span>) <span class='co'># "S. pyogenes"</span></div><div class='output co'>#&gt; [1] "S. pyogenes"</div><div class='input'><span class='fu'>mo_shortname</span>(<span class='st'>"S. pyo"</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># "GAS" ('Group A streptococci')</span></div><div class='output co'>#&gt; [1] "GAS"</div><div class='input'>
<span class='fu'>mo_fullname</span>(<span class='st'>"S. pyo"</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># "Streptococcus group A"</span>
<span class='fu'>mo_shortname</span>(<span class='st'>"S. pyo"</span>) <span class='co'># "S. pyogenes"</span>
<span class='fu'>mo_shortname</span>(<span class='st'>"S. pyo"</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>) <span class='co'># "GAS" ('Group A streptococci')</span>
<span class='co'># Language support for German, Dutch, Spanish, Portuguese, Italian and French</span> <span class='co'># Language support for German, Dutch, Spanish, Portuguese, Italian and French</span>
<span class='fu'>mo_gramstain</span>(<span class='st'>"E. coli"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"de"</span>) <span class='co'># "Gramnegativ"</span> <span class='fu'>mo_gramstain</span>(<span class='st'>"E. coli"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"de"</span>) <span class='co'># "Gramnegativ"</span></div><div class='output co'>#&gt; [1] "Gramnegativ"</div><div class='input'><span class='fu'>mo_gramstain</span>(<span class='st'>"E. coli"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"nl"</span>) <span class='co'># "Gram-negatief"</span></div><div class='output co'>#&gt; [1] "Gram-negatief"</div><div class='input'><span class='fu'>mo_gramstain</span>(<span class='st'>"E. coli"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"es"</span>) <span class='co'># "Gram negativo"</span></div><div class='output co'>#&gt; [1] "Gram negativo"</div><div class='input'>
<span class='fu'>mo_gramstain</span>(<span class='st'>"E. coli"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"nl"</span>) <span class='co'># "Gram-negatief"</span>
<span class='fu'>mo_gramstain</span>(<span class='st'>"E. coli"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"es"</span>) <span class='co'># "Gram negativo"</span>
<span class='co'># mo_type is equal to mo_kingdom, but mo_kingdom will remain official</span> <span class='co'># mo_type is equal to mo_kingdom, but mo_kingdom will remain official</span>
<span class='fu'>mo_kingdom</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bacteria" on a German system</span> <span class='fu'>mo_kingdom</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bacteria" on a German system</span></div><div class='output co'>#&gt; [1] "Bacteria"</div><div class='input'><span class='fu'>mo_type</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bakterien" on a German system</span></div><div class='output co'>#&gt; [1] "Bacteriën"</div><div class='input'><span class='fu'>mo_type</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bacteria" on an English system</span></div><div class='output co'>#&gt; [1] "Bacteriën"</div><div class='input'>
<span class='fu'>mo_type</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bakterien" on a German system</span>
<span class='fu'>mo_type</span>(<span class='st'>"E. coli"</span>) <span class='co'># "Bacteria" on an English system</span>
<span class='fu'>mo_fullname</span>(<span class='st'>"S. pyogenes"</span>, <span class='fu'>mo_fullname</span>(<span class='st'>"S. pyogenes"</span>,
<span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"de"</span>) <span class='co'># "Streptococcus Gruppe A"</span> <span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"de"</span>) <span class='co'># "Streptococcus Gruppe A"</span></div><div class='output co'>#&gt; [1] "Streptococcus Gruppe A"</div><div class='input'><span class='fu'>mo_fullname</span>(<span class='st'>"S. pyogenes"</span>,
<span class='fu'>mo_fullname</span>(<span class='st'>"S. pyogenes"</span>,
<span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"nl"</span>) <span class='co'># "Streptococcus groep A"</span> <span class='kw'>language</span> <span class='kw'>=</span> <span class='st'>"nl"</span>) <span class='co'># "Streptococcus groep A"</span></div><div class='output co'>#&gt; [1] "Streptococcus groep A"</div><div class='input'>
<span class='co'># Get a list with the complete taxonomy (subkingdom to subspecies)</span> <span class='co'># Get a list with the complete taxonomy (subkingdom to subspecies)</span>
<span class='fu'>mo_taxonomy</span>(<span class='st'>"E. coli"</span>) <span class='fu'>mo_taxonomy</span>(<span class='st'>"E. coli"</span>)</div><div class='output co'>#&gt; $kingdom
<span class='co'># }</span></pre> #&gt; [1] "Bacteria"
#&gt;
#&gt; $subkingdom
#&gt; [1] "Negibacteria"
#&gt;
#&gt; $phylum
#&gt; [1] "Proteobacteria"
#&gt;
#&gt; $class
#&gt; [1] "Gammaproteobacteria"
#&gt;
#&gt; $order
#&gt; [1] "Enterobacteriales"
#&gt;
#&gt; $family
#&gt; [1] "Enterobacteriaceae"
#&gt;
#&gt; $genus
#&gt; [1] "Escherichia"
#&gt;
#&gt; $species
#&gt; [1] "coli"
#&gt;
#&gt; $subspecies
#&gt; [1] NA
#&gt; </div></span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -254,49 +254,43 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># septic_patients is a data set available in the AMR package. It is true, genuine data.</span>
<span class='co'># septic_patients is a data set available in the AMR package. It is true, genuine data.</span> ?<span class='no'>septic_patients</span></div><div class='output co'>#&gt; <span class='message'>Rendering development documentation for 'septic_patients'</span></div><div class='input'>
?<span class='no'>septic_patients</span>
<span class='co'># Calculate resistance</span> <span class='co'># Calculate resistance</span>
<span class='fu'>portion_R</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>) <span class='fu'>portion_R</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 0.5827645</div><div class='input'><span class='fu'>portion_IR</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 0.5853242</div><div class='input'>
<span class='fu'>portion_IR</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)
<span class='co'># Or susceptibility</span> <span class='co'># Or susceptibility</span>
<span class='fu'>portion_S</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>) <span class='fu'>portion_S</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 0.4146758</div><div class='input'><span class='fu'>portion_SI</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 0.4172355</div><div class='input'>
<span class='fu'>portion_SI</span>(<span class='no'>septic_patients</span>$<span class='no'>amox</span>)
<span class='co'># Do the above with pipes:</span> <span class='co'># Do the above with pipes:</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>) <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_R</span>(<span class='no'>amox</span>) <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_R</span>(<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 0.5827645</div><div class='input'><span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_IR</span>(<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 0.5853242</div><div class='input'><span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 0.4146758</div><div class='input'><span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>amox</span>)</div><div class='output co'>#&gt; [1] 0.4172355</div><div class='input'>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_IR</span>(<span class='no'>amox</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>amox</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>amox</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>cipr</span>), <span class='fu'><a href='http://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>cipr</span>),
<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>cipr</span>)) <span class='co'># n_rsi works like n_distinct in dplyr</span> <span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>cipr</span>)) <span class='co'># n_rsi works like n_distinct in dplyr</span></div><div class='output co'>#&gt; <span style='color: #949494;'># A tibble: 4 x 3</span><span>
#&gt; hospital_id p n
#&gt; </span><span style='color: #949494;font-style: italic;'>&lt;fct&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;dbl&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span>
#&gt; </span><span style='color: #BCBCBC;'>1</span><span> A 0.860 207
#&gt; </span><span style='color: #BCBCBC;'>2</span><span> B 0.760 499
#&gt; </span><span style='color: #BCBCBC;'>3</span><span> C 0.688 202
#&gt; </span><span style='color: #BCBCBC;'>4</span><span> D 0.830 501</div><div class='input'>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>R</span> <span class='kw'>=</span> <span class='fu'>portion_R</span>(<span class='no'>cipr</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>), <span class='fu'><a href='http://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>R</span> <span class='kw'>=</span> <span class='fu'>portion_R</span>(<span class='no'>cipr</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>I</span> <span class='kw'>=</span> <span class='fu'>portion_I</span>(<span class='no'>cipr</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>), <span class='kw'>I</span> <span class='kw'>=</span> <span class='fu'>portion_I</span>(<span class='no'>cipr</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>S</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>cipr</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>), <span class='kw'>S</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>cipr</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>cipr</span>), <span class='co'># works like n_distinct in dplyr</span> <span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>cipr</span>), <span class='co'># works like n_distinct in dplyr</span>
<span class='kw'>total</span> <span class='kw'>=</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/n.html'>n</a></span>()) <span class='co'># NOT the amount of tested isolates!</span> <span class='kw'>total</span> <span class='kw'>=</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/n.html'>n</a></span>()) <span class='co'># NOT the amount of tested isolates!</span></div><div class='output co'>#&gt; </span><span style='color: #949494;'># A tibble: 4 x 6</span><span>
#&gt; hospital_id R I S n total
#&gt; </span><span style='color: #949494;font-style: italic;'>&lt;fct&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;chr&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;chr&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;chr&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span>
#&gt; </span><span style='color: #BCBCBC;'>1</span><span> A 12.6% 1.4% 86.0% 207 321
#&gt; </span><span style='color: #BCBCBC;'>2</span><span> B 17.0% 7.0% 76.0% 499 663
#&gt; </span><span style='color: #BCBCBC;'>3</span><span> C 20.3% 10.9% 68.8% 202 254
#&gt; </span><span style='color: #BCBCBC;'>4</span><span> D 15.2% 1.8% 83.0% 501 762</div><div class='input'>
<span class='co'># Calculate co-resistance between amoxicillin/clav acid and gentamicin,</span> <span class='co'># Calculate co-resistance between amoxicillin/clav acid and gentamicin,</span>
<span class='co'># so we can see that combination therapy does a lot more than mono therapy:</span> <span class='co'># so we can see that combination therapy does a lot more than mono therapy:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>amcl</span>) <span class='co'># S = 67.1%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>amcl</span>) <span class='co'># S = 67.1%</span></div><div class='output co'>#&gt; [1] 0.7062363</div><div class='input'><span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>amcl</span>) <span class='co'># n = 1576</span></div><div class='output co'>#&gt; [1] 1828</div><div class='input'>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>amcl</span>) <span class='co'># n = 1576</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>gent</span>) <span class='co'># S = 74.0%</span></div><div class='output co'>#&gt; [1] 0.7396226</div><div class='input'><span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>gent</span>) <span class='co'># n = 1855</span></div><div class='output co'>#&gt; [1] 1855</div><div class='input'>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>amcl</span>, <span class='no'>gent</span>) <span class='co'># S = 92.0%</span></div><div class='output co'>#&gt; [1] 0.9210074</div><div class='input'><span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>amcl</span>, <span class='no'>gent</span>) <span class='co'># n = 1517</span></div><div class='output co'>#&gt; [1] 1747</div><div class='input'>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>gent</span>) <span class='co'># S = 74.0%</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>gent</span>) <span class='co'># n = 1855</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>amcl</span>, <span class='no'>gent</span>) <span class='co'># S = 92.0%</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>amcl</span>, <span class='no'>gent</span>) <span class='co'># n = 1517</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
@ -305,21 +299,43 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<span class='kw'>genta_p</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>gent</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>), <span class='kw'>genta_p</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>gent</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>genta_n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>gent</span>), <span class='kw'>genta_n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>gent</span>),
<span class='kw'>combination_p</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>cipr</span>, <span class='no'>gent</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>), <span class='kw'>combination_p</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>cipr</span>, <span class='no'>gent</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>combination_n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>cipr</span>, <span class='no'>gent</span>)) <span class='kw'>combination_n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>cipr</span>, <span class='no'>gent</span>))</div><div class='output co'>#&gt; </span><span style='color: #949494;'># A tibble: 4 x 7</span><span>
#&gt; hospital_id cipro_p cipro_n genta_p genta_n combination_p combination_n
#&gt; </span><span style='color: #949494;font-style: italic;'>&lt;fct&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;chr&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;chr&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;chr&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span>
#&gt; </span><span style='color: #BCBCBC;'>1</span><span> A 86.0% 207 76.0% 300 95.0% 202
#&gt; </span><span style='color: #BCBCBC;'>2</span><span> B 76.0% 499 71.5% 606 91.4% 488
#&gt; </span><span style='color: #BCBCBC;'>3</span><span> C 68.8% 202 75.8% 240 91.5% 201
#&gt; </span><span style='color: #BCBCBC;'>4</span><span> D 83.0% 501 74.6% 709 95.0% 499</div><div class='input'>
<span class='co'># Get portions S/I/R immediately of all rsi columns</span> <span class='co'># Get portions S/I/R immediately of all rsi columns</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>amox</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>portion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>) <span class='fu'>portion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</div><div class='output co'>#&gt; Interpretation Antibiotic Value
#&gt; 1 S amox 0.414675768
#&gt; 2 I amox 0.002559727
#&gt; 3 R amox 0.582764505
#&gt; 4 S cipr 0.789212207
#&gt; 5 I cipr 0.048970901
#&gt; 6 R cipr 0.161816891</div><div class='input'>
<span class='co'># It also supports grouping variables</span> <span class='co'># It also supports grouping variables</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>hospital_id</span>, <span class='no'>amox</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>hospital_id</span>, <span class='no'>amox</span>, <span class='no'>cipr</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>portion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>) <span class='fu'>portion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</div><div class='output co'>#&gt; </span><span style='color: #949494;'># A tibble: 24 x 4</span><span>
#&gt; Interpretation hospital_id Antibiotic Value
#&gt; </span><span style='color: #949494;font-style: italic;'>&lt;ord&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;fct&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;chr&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;dbl&gt;</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 1</span><span> S A amox 0.42
#&gt; </span><span style='color: #BCBCBC;'> 2</span><span> S B amox 0.378
#&gt; </span><span style='color: #BCBCBC;'> 3</span><span> S C amox 0.373
#&gt; </span><span style='color: #BCBCBC;'> 4</span><span> S D amox 0.454
#&gt; </span><span style='color: #BCBCBC;'> 5</span><span> I A amox 0
#&gt; </span><span style='color: #BCBCBC;'> 6</span><span> I B amox 0.002</span><span style='text-decoration: underline;'>68</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 7</span><span> I C amox 0
#&gt; </span><span style='color: #BCBCBC;'> 8</span><span> I D amox 0.004</span><span style='text-decoration: underline;'>07</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 9</span><span> R A amox 0.580
#&gt; </span><span style='color: #BCBCBC;'>10</span><span> R B amox 0.619
#&gt; </span><span style='color: #949494;'># ... with 14 more rows</span><span></div><div class='input'>
</div></span><span class='co'># NOT RUN {</span>
<span class='co'># }</span><span class='co'># NOT RUN {</span>
<span class='co'># calculate current empiric combination therapy of Helicobacter gastritis:</span> <span class='co'># calculate current empiric combination therapy of Helicobacter gastritis:</span>
<span class='no'>my_table</span> <span class='kw'>%&gt;%</span> <span class='no'>my_table</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>, <span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>,

View File

@ -255,7 +255,7 @@
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>, <span class='fu'><a href='http://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>,
<span class='no'>genus</span> <span class='kw'>==</span> <span class='st'>"Haemophilus"</span>) <span class='kw'>%&gt;%</span> <span class='no'>genus</span> <span class='kw'>==</span> <span class='st'>"Haemophilus"</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>resistance_predict</span>(<span class='no'>amcl</span>, <span class='no'>date</span>) <span class='fu'>resistance_predict</span>(<span class='no'>amcl</span>, <span class='no'>date</span>)
<span class='co'># }</span><span class='co'># NOT RUN {</span> <span class='co'># }</span><div class='input'>
<span class='co'># real live example:</span> <span class='co'># real live example:</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>) <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
@ -273,8 +273,56 @@
<span class='kw'>col_date</span> <span class='kw'>=</span> <span class='st'>"date"</span>, <span class='kw'>col_date</span> <span class='kw'>=</span> <span class='st'>"date"</span>,
<span class='kw'>year_max</span> <span class='kw'>=</span> <span class='fl'>2025</span>, <span class='kw'>year_max</span> <span class='kw'>=</span> <span class='fl'>2025</span>,
<span class='kw'>preserve_measurements</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>preserve_measurements</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>0</span>) <span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>0</span>)</div><div class='output co'>#&gt; <span class='message'><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>mo</span><span style='color: #0000BB;'>` as input for `col_mo`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>date</span><span style='color: #0000BB;'>` as input for `col_date`.</span><span></span></div><div class='output co'>#&gt; <span class='message'></span><span style='color: #0000BB;'>NOTE: Using column `</span><span style='color: #0000BB;font-weight: bold;'>patient_id</span><span style='color: #0000BB;'>` as input for `col_patient_id`.</span><span></span></div><div class='output co'>#&gt; <span class='message'>=&gt; Found </span><span style='font-weight: bold;'>1,317 first isolates</span><span> (65.9% of total)</span></div><div class='output co'>#&gt;
#&gt; Logistic regression model (logit) with binomial distribution
#&gt; ------------------------------------------------------------
#&gt;
#&gt; Call:
#&gt; glm(formula = cbind(R, S) ~ year, family = binomial)
#&gt;
#&gt; Deviance Residuals:
#&gt; Min 1Q Median 3Q Max
#&gt; -1.0751 -0.4675 -0.2840 -0.1530 1.5028
#&gt;
#&gt; Coefficients:
#&gt; Estimate Std. Error z value Pr(&gt;|z|)
#&gt; (Intercept) -686.7518 342.1219 -2.007 0.0447 *
#&gt; year 0.3393 0.1698 1.998 0.0457 *
#&gt; ---
#&gt; Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
#&gt;
#&gt; (Dispersion parameter for binomial family taken to be 1)
#&gt;
#&gt; Null deviance: 13.5547 on 15 degrees of freedom
#&gt; Residual deviance: 6.8145 on 14 degrees of freedom
#&gt; AIC: 19.128
#&gt;
#&gt; Number of Fisher Scoring iterations: 6
#&gt; </div><div class='output co'>#&gt; year value se_min se_max observations observed estimated
#&gt; 1 2002 0.00000000 NA NA 12 0.00000000 0.0005265096
#&gt; 2 2003 0.00000000 NA NA 13 0.00000000 0.0007390158
#&gt; 3 2004 0.00000000 NA NA 12 0.00000000 0.0010372031
#&gt; 4 2005 0.00000000 NA NA 15 0.00000000 0.0014555316
#&gt; 5 2006 0.00000000 NA NA 16 0.00000000 0.0020422369
#&gt; 6 2007 0.00000000 NA NA 17 0.00000000 0.0028647568
#&gt; 7 2008 0.00000000 NA NA 17 0.00000000 0.0040172166
#&gt; 8 2009 0.00000000 NA NA 18 0.00000000 0.0056306802
#&gt; 9 2010 0.00000000 NA NA 13 0.00000000 0.0078870391
#&gt; 10 2011 0.04761905 NA NA 21 0.04761905 0.0110375429
#&gt; 11 2012 0.00000000 NA NA 10 0.00000000 0.0154269569
#&gt; 12 2013 0.00000000 NA NA 13 0.00000000 0.0215239636
#&gt; 13 2014 0.00000000 NA NA 19 0.00000000 0.0299572977
#&gt; 14 2015 0.14285714 NA NA 14 0.14285714 0.0415545799
#&gt; 15 2016 0.04761905 NA NA 21 0.04761905 0.0573759332
#&gt; 16 2017 0.05000000 NA NA 20 0.05000000 0.0787262663
#&gt; 17 2018 0.10711851 0.03829468 0.1759423 NA NA 0.1071185079
#&gt; 18 2019 0.14414813 0.03838570 0.2499106 NA NA 0.1441481336
#&gt; 19 2020 0.19123682 0.03582031 0.3466533 NA NA 0.1912368226
#&gt; 20 2021 0.24922848 0.03244999 0.4660070 NA NA 0.2492284792
#&gt; 21 2022 0.31789357 0.03249431 0.6032928 NA NA 0.3178935725
#&gt; 22 2023 0.39551054 0.04249603 0.7485251 NA NA 0.3955105423
#&gt; 23 2024 0.47877663 0.06981495 0.8877383 NA NA 0.4787766284
#&gt; 24 2025 0.56323896 0.11983506 1.0000000 NA NA 0.5632389556</div><div class='input'>
<span class='co'># create nice plots with ggplot</span> <span class='co'># create nice plots with ggplot</span>
<span class='kw'>if</span> (!<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>require</a></span>(<span class='no'>ggplot2</span>)) { <span class='kw'>if</span> (!<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>require</a></span>(<span class='no'>ggplot2</span>)) {
@ -300,8 +348,7 @@
<span class='kw'>y</span> <span class='kw'>=</span> <span class='st'>"%IR"</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='st'>"%IR"</span>,
<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"Year"</span>) + <span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"Year"</span>) +
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggtheme.html'>theme_minimal</a></span>(<span class='kw'>base_size</span> <span class='kw'>=</span> <span class='fl'>13</span>) <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggtheme.html'>theme_minimal</a></span>(<span class='kw'>base_size</span> <span class='kw'>=</span> <span class='fl'>13</span>)
} }</div></span></pre>
<span class='co'># }</span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -186,8 +186,7 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><div class='input'><span class='co'># ----------- #</span>
<span class='co'># ----------- #</span>
<span class='co'># PREPARATION #</span> <span class='co'># PREPARATION #</span>
<span class='co'># ----------- #</span> <span class='co'># ----------- #</span>
@ -199,8 +198,7 @@
<span class='co'># Add first isolates to our data set:</span> <span class='co'># Add first isolates to our data set:</span>
<span class='no'>my_data</span> <span class='kw'>&lt;-</span> <span class='no'>my_data</span> <span class='kw'>%&gt;%</span> <span class='no'>my_data</span> <span class='kw'>&lt;-</span> <span class='no'>my_data</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>first_isolates</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>my_data</span>, <span class='st'>"date"</span>, <span class='st'>"patient_id"</span>, <span class='st'>"mo"</span>)) <span class='fu'><a href='http://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>first_isolates</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>my_data</span>, <span class='st'>"date"</span>, <span class='st'>"patient_id"</span>, <span class='st'>"mo"</span>))</div><div class='output co'>#&gt; <span class='message'>=&gt; Found <span style='font-weight: bold;'>1,317 first isolates</span><span> (65.9% of total)</span></div><div class='input'>
<span class='co'># -------- #</span> <span class='co'># -------- #</span>
<span class='co'># ANALYSIS #</span> <span class='co'># ANALYSIS #</span>
<span class='co'># -------- #</span> <span class='co'># -------- #</span>
@ -213,8 +211,13 @@
<span class='no'>first_isolates</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>) <span class='kw'>%&gt;%</span> <span class='no'>first_isolates</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>amox</span>), <span class='fu'><a href='http://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>amox</span>),
<span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'><a href='portion.html'>portion_IR</a></span>(<span class='no'>amox</span>)) <span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'><a href='portion.html'>portion_IR</a></span>(<span class='no'>amox</span>))</div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 19 results available (minimum set to 30).</span></div><div class='output co'>#&gt; </span><span style='color: #949494;'># A tibble: 4 x 3</span><span>
#&gt; hospital_id n p
#&gt; </span><span style='color: #949494;font-style: italic;'>&lt;fct&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;dbl&gt;</span><span>
#&gt; </span><span style='color: #BCBCBC;'>1</span><span> A 19 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'>2</span><span> B 65 0.477
#&gt; </span><span style='color: #BCBCBC;'>3</span><span> C 35 0.543
#&gt; </span><span style='color: #BCBCBC;'>4</span><span> D 94 0.5 </div><div class='input'>
<span class='co'># 2. Get the amoxicillin/clavulanic acid resistance</span> <span class='co'># 2. Get the amoxicillin/clavulanic acid resistance</span>
<span class='co'># percentages of E. coli, trend over the years:</span> <span class='co'># percentages of E. coli, trend over the years:</span>
@ -224,8 +227,25 @@
<span class='no'>first_isolates</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>) <span class='kw'>%&gt;%</span> <span class='no'>first_isolates</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>year</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/format'>format</a></span>(<span class='no'>date</span>, <span class='st'>"%Y"</span>)) <span class='kw'>%&gt;%</span> <span class='fu'><a href='http://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>year</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/format'>format</a></span>(<span class='no'>date</span>, <span class='st'>"%Y"</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='http://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>amcl</span>), <span class='fu'><a href='http://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>amcl</span>),
<span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'><a href='portion.html'>portion_IR</a></span>(<span class='no'>amcl</span>, <span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>20</span>)) <span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'><a href='portion.html'>portion_IR</a></span>(<span class='no'>amcl</span>, <span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>20</span>))</div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 13 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 14 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 13 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 15 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 16 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 17 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 17 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 18 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 13 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 10 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 13 results available (minimum set to 20).</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Introducing NA: only 14 results available (minimum set to 20).</span></div><div class='output co'>#&gt; </span><span style='color: #949494;'># A tibble: 16 x 3</span><span>
<span class='co'># }</span></pre> #&gt; year n p
#&gt; </span><span style='color: #949494;font-style: italic;'>&lt;chr&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;int&gt;</span><span> </span><span style='color: #949494;font-style: italic;'>&lt;dbl&gt;</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 1</span><span> 2002 13 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 2</span><span> 2003 14 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 3</span><span> 2004 13 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 4</span><span> 2005 15 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 5</span><span> 2006 16 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 6</span><span> 2007 17 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 7</span><span> 2008 17 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 8</span><span> 2009 18 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'> 9</span><span> 2010 13 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'>10</span><span> 2011 21 0.095</span><span style='text-decoration: underline;'>2</span><span>
#&gt; </span><span style='color: #BCBCBC;'>11</span><span> 2012 10 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'>12</span><span> 2013 13 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'>13</span><span> 2014 20 0.2
#&gt; </span><span style='color: #BCBCBC;'>14</span><span> 2015 14 </span><span style='color: #BB0000;'>NA</span><span>
#&gt; </span><span style='color: #BCBCBC;'>15</span><span> 2016 21 0.190
#&gt; </span><span style='color: #BCBCBC;'>16</span><span> 2017 20 0.4 </div></span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -67,8 +67,8 @@ The `LETTERS` object is available in R - it's a vector with 26 characters: `A` t
```{r create gender} ```{r create gender}
patients_table <- data.frame(patient_id = patients, patients_table <- data.frame(patient_id = patients,
gender = c(strrep("M", 135), gender = c(rep("M", 135),
strrep("F", 125))) rep("F", 125)))
``` ```
The first 135 patient IDs are now male, the other 125 are female. The first 135 patient IDs are now male, the other 125 are female.