mirror of
https://github.com/msberends/AMR.git
synced 2024-12-27 12:06:14 +01:00
1435 lines
50 KiB
HTML
1435 lines
50 KiB
HTML
<!DOCTYPE html>
|
||
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||
<meta charset="utf-8">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Creating Frequency Tables • AMR (for R)</title>
|
||
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
|
||
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
|
||
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
|
||
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png">
|
||
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
|
||
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
|
||
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous">
|
||
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- sticky kit --><script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
|
||
<script src="../pkgdown.js"></script><!-- docsearch --><script src="../docsearch.js"></script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.css" integrity="sha256-QOSRU/ra9ActyXkIBbiIB144aDBdtvXBcNc3OTNuX/Q=" crossorigin="anonymous">
|
||
<link href="../docsearch.css" rel="stylesheet">
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.min.js" integrity="sha256-4HLtjeVgH0eIB3aZ9mLYF6E8oU5chNdjU6p6rrXpl9U=" crossorigin="anonymous"></script><link href="../extra.css" rel="stylesheet">
|
||
<script src="../extra.js"></script><meta property="og:title" content="Creating Frequency Tables">
|
||
<meta property="og:description" content="">
|
||
<meta property="og:image" content="https://msberends.gitlab.io/logo.png">
|
||
<meta name="twitter:card" content="summary">
|
||
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
|
||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||
<![endif]-->
|
||
</head>
|
||
<body>
|
||
<div class="container template-article">
|
||
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||
<div class="container">
|
||
<div class="navbar-header">
|
||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||
<span class="sr-only">Toggle navigation</span>
|
||
<span class="icon-bar"></span>
|
||
<span class="icon-bar"></span>
|
||
<span class="icon-bar"></span>
|
||
</button>
|
||
<span class="navbar-brand">
|
||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9008</span>
|
||
</span>
|
||
</div>
|
||
|
||
<div id="navbar" class="navbar-collapse collapse">
|
||
<ul class="nav navbar-nav">
|
||
<li>
|
||
<a href="../index.html">
|
||
<span class="fa fa-home"></span>
|
||
|
||
Home
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="../articles/AMR.html">
|
||
<span class="fa fa-directions"></span>
|
||
|
||
Get Started
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="../reference/">
|
||
<span class="fa fa-book-open"></span>
|
||
|
||
Manual
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="../authors.html">
|
||
<span class="fa fa-users"></span>
|
||
|
||
Authors
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="../news/">
|
||
<span class="far fa far fa-newspaper"></span>
|
||
|
||
Changelog
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="https://gitlab.com/msberends/AMR">
|
||
<span class="fab fa fab fa-gitlab"></span>
|
||
|
||
Source Code
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
<ul class="nav navbar-nav navbar-right">
|
||
<li>
|
||
<a href="../LICENSE-text.html">
|
||
<span class="fa fa-book"></span>
|
||
|
||
Licence
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
<form class="navbar-form navbar-right" role="search">
|
||
<div class="form-group">
|
||
<input type="search" class="form-control" name="search-input" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off">
|
||
</div>
|
||
</form>
|
||
|
||
</div>
|
||
<!--/.nav-collapse -->
|
||
</div>
|
||
<!--/.container -->
|
||
</div>
|
||
<!--/.navbar -->
|
||
|
||
|
||
</header><div class="row">
|
||
<div class="col-md-9 contents">
|
||
<div class="page-header toc-ignore">
|
||
<h1>Creating Frequency Tables</h1>
|
||
<h4 class="author">Matthijs S. Berends</h4>
|
||
|
||
|
||
|
||
<div class="hidden name"><code>freq.Rmd</code></div>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
<div id="introduction" class="section level2">
|
||
<h2 class="hasAnchor">
|
||
<a href="#introduction" class="anchor"></a>Introduction</h2>
|
||
<p>Frequency tables (or frequency distributions) are summaries of the distribution of values in a sample. With the <code>freq</code> function, you can create univariate frequency tables. Multiple variables will be pasted into one variable, so it forces a univariate distribution. We take the <code>septic_patients</code> dataset (included in this AMR package) as example.</p>
|
||
</div>
|
||
<div id="frequencies-of-one-variable" class="section level2">
|
||
<h2 class="hasAnchor">
|
||
<a href="#frequencies-of-one-variable" class="anchor"></a>Frequencies of one variable</h2>
|
||
<p>To only show and quickly review the content of one variable, you can just select this variable in various ways. Let’s say we want to get the frequencies of the <code>gender</code> variable of the <code>septic_patients</code> dataset:</p>
|
||
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1">septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</a></code></pre></div>
|
||
<p><strong>Frequency table of <code>gender</code></strong></p>
|
||
<table class="table">
|
||
<thead><tr class="header">
|
||
<th align="left"></th>
|
||
<th align="left">Item</th>
|
||
<th align="right">Count</th>
|
||
<th align="right">Percent</th>
|
||
<th align="right">Cum. Count</th>
|
||
<th align="right">Cum. Percent</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td align="left">1</td>
|
||
<td align="left">M</td>
|
||
<td align="right">1,031</td>
|
||
<td align="right">51.6%</td>
|
||
<td align="right">1,031</td>
|
||
<td align="right">51.6%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">2</td>
|
||
<td align="left">F</td>
|
||
<td align="right">969</td>
|
||
<td align="right">48.5%</td>
|
||
<td align="right">2,000</td>
|
||
<td align="right">100.0%</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>This immediately shows the class of the variable, its length and availability (i.e. the amount of <code>NA</code>), the amount of unique values and (most importantly) that among septic patients men are more prevalent than women.</p>
|
||
</div>
|
||
<div id="frequencies-of-more-than-one-variable" class="section level2">
|
||
<h2 class="hasAnchor">
|
||
<a href="#frequencies-of-more-than-one-variable" class="anchor"></a>Frequencies of more than one variable</h2>
|
||
<p>Multiple variables will be pasted into one variable to review individual cases, keeping a univariate frequency table.</p>
|
||
<p>For illustration, we could add some more variables to the <code>septic_patients</code> dataset to learn about bacterial properties:</p>
|
||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" data-line-number="1">my_patients <-<span class="st"> </span>septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/join.html">left_join_microorganisms</a></span>()</a>
|
||
<a class="sourceLine" id="cb2-2" data-line-number="2">Joining, by =<span class="st"> "mo"</span></a></code></pre></div>
|
||
<p>Now all variables of the <code>microorganisms</code> dataset have been joined to the <code>septic_patients</code> dataset. The <code>microorganisms</code> dataset consists of the following variables:</p>
|
||
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/colnames">colnames</a></span>(microorganisms)</a>
|
||
<a class="sourceLine" id="cb3-2" data-line-number="2"> [<span class="dv">1</span>] <span class="st">"mo"</span> <span class="st">"tsn"</span> <span class="st">"genus"</span> <span class="st">"species"</span> <span class="st">"subspecies"</span></a>
|
||
<a class="sourceLine" id="cb3-3" data-line-number="3"> [<span class="dv">6</span>] <span class="st">"fullname"</span> <span class="st">"family"</span> <span class="st">"order"</span> <span class="st">"class"</span> <span class="st">"phylum"</span> </a>
|
||
<a class="sourceLine" id="cb3-4" data-line-number="4">[<span class="dv">11</span>] <span class="st">"subkingdom"</span> <span class="st">"kingdom"</span> <span class="st">"gramstain"</span> <span class="st">"prevalence"</span> <span class="st">"ref"</span> </a></code></pre></div>
|
||
<p>If we compare the dimensions between the old and new dataset, we can see that these 14 variables were added:</p>
|
||
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/dim">dim</a></span>(septic_patients)</a>
|
||
<a class="sourceLine" id="cb4-2" data-line-number="2">[<span class="dv">1</span>] <span class="dv">2000</span> <span class="dv">49</span></a>
|
||
<a class="sourceLine" id="cb4-3" data-line-number="3"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/dim">dim</a></span>(my_patients)</a>
|
||
<a class="sourceLine" id="cb4-4" data-line-number="4">[<span class="dv">1</span>] <span class="dv">2000</span> <span class="dv">63</span></a></code></pre></div>
|
||
<p>So now the <code>genus</code> and <code>species</code> variables are available. A frequency table of these combined variables can be created like this:</p>
|
||
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1">my_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(genus, species)</a></code></pre></div>
|
||
<p><strong>Frequency table of <code>genus</code> and <code>species</code></strong></p>
|
||
<table class="table">
|
||
<thead><tr class="header">
|
||
<th align="left"></th>
|
||
<th align="left">Item</th>
|
||
<th align="right">Count</th>
|
||
<th align="right">Percent</th>
|
||
<th align="right">Cum. Count</th>
|
||
<th align="right">Cum. Percent</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td align="left">1</td>
|
||
<td align="left">Escherichia coli</td>
|
||
<td align="right">467</td>
|
||
<td align="right">23.4%</td>
|
||
<td align="right">467</td>
|
||
<td align="right">23.4%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">2</td>
|
||
<td align="left">Staphylococcus coagulase negative</td>
|
||
<td align="right">313</td>
|
||
<td align="right">15.7%</td>
|
||
<td align="right">780</td>
|
||
<td align="right">39.0%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">3</td>
|
||
<td align="left">Staphylococcus aureus</td>
|
||
<td align="right">235</td>
|
||
<td align="right">11.8%</td>
|
||
<td align="right">1,015</td>
|
||
<td align="right">50.7%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">4</td>
|
||
<td align="left">Staphylococcus epidermidis</td>
|
||
<td align="right">174</td>
|
||
<td align="right">8.7%</td>
|
||
<td align="right">1,189</td>
|
||
<td align="right">59.5%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">5</td>
|
||
<td align="left">Streptococcus pneumoniae</td>
|
||
<td align="right">117</td>
|
||
<td align="right">5.9%</td>
|
||
<td align="right">1,306</td>
|
||
<td align="right">65.3%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">6</td>
|
||
<td align="left">Staphylococcus hominis</td>
|
||
<td align="right">81</td>
|
||
<td align="right">4.1%</td>
|
||
<td align="right">1,387</td>
|
||
<td align="right">69.4%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">7</td>
|
||
<td align="left">Klebsiella pneumoniae</td>
|
||
<td align="right">58</td>
|
||
<td align="right">2.9%</td>
|
||
<td align="right">1,445</td>
|
||
<td align="right">72.3%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">8</td>
|
||
<td align="left">Enterococcus faecalis</td>
|
||
<td align="right">39</td>
|
||
<td align="right">2.0%</td>
|
||
<td align="right">1,484</td>
|
||
<td align="right">74.2%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">9</td>
|
||
<td align="left">Proteus mirabilis</td>
|
||
<td align="right">36</td>
|
||
<td align="right">1.8%</td>
|
||
<td align="right">1,520</td>
|
||
<td align="right">76.0%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">10</td>
|
||
<td align="left">Pseudomonas aeruginosa</td>
|
||
<td align="right">30</td>
|
||
<td align="right">1.5%</td>
|
||
<td align="right">1,550</td>
|
||
<td align="right">77.5%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">11</td>
|
||
<td align="left">Serratia marcescens</td>
|
||
<td align="right">25</td>
|
||
<td align="right">1.3%</td>
|
||
<td align="right">1,575</td>
|
||
<td align="right">78.8%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">12</td>
|
||
<td align="left">Enterobacter cloacae</td>
|
||
<td align="right">23</td>
|
||
<td align="right">1.2%</td>
|
||
<td align="right">1,598</td>
|
||
<td align="right">79.9%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">13</td>
|
||
<td align="left">Enterococcus faecium</td>
|
||
<td align="right">21</td>
|
||
<td align="right">1.1%</td>
|
||
<td align="right">1,619</td>
|
||
<td align="right">81.0%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">14</td>
|
||
<td align="left">Staphylococcus capitis</td>
|
||
<td align="right">21</td>
|
||
<td align="right">1.1%</td>
|
||
<td align="right">1,640</td>
|
||
<td align="right">82.0%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">15</td>
|
||
<td align="left">Bacteroides fragilis</td>
|
||
<td align="right">20</td>
|
||
<td align="right">1.0%</td>
|
||
<td align="right">1,660</td>
|
||
<td align="right">83.0%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">16</td>
|
||
<td align="left">Enterococcus species</td>
|
||
<td align="right">20</td>
|
||
<td align="right">1.0%</td>
|
||
<td align="right">1,680</td>
|
||
<td align="right">84.0%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">17</td>
|
||
<td align="left">Streptococcus group B</td>
|
||
<td align="right">18</td>
|
||
<td align="right">0.9%</td>
|
||
<td align="right">1,698</td>
|
||
<td align="right">84.9%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">18</td>
|
||
<td align="left">Klebsiella oxytoca</td>
|
||
<td align="right">16</td>
|
||
<td align="right">0.8%</td>
|
||
<td align="right">1,714</td>
|
||
<td align="right">85.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">19</td>
|
||
<td align="left">Streptococcus pyogenes</td>
|
||
<td align="right">16</td>
|
||
<td align="right">0.8%</td>
|
||
<td align="right">1,730</td>
|
||
<td align="right">86.5%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">20</td>
|
||
<td align="left">Streptococcus dysgalactiae</td>
|
||
<td align="right">14</td>
|
||
<td align="right">0.7%</td>
|
||
<td align="right">1,744</td>
|
||
<td align="right">87.2%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">21</td>
|
||
<td align="left">Streptococcus group A</td>
|
||
<td align="right">13</td>
|
||
<td align="right">0.7%</td>
|
||
<td align="right">1,757</td>
|
||
<td align="right">87.9%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">22</td>
|
||
<td align="left">Streptococcus mitis</td>
|
||
<td align="right">13</td>
|
||
<td align="right">0.7%</td>
|
||
<td align="right">1,770</td>
|
||
<td align="right">88.5%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">23</td>
|
||
<td align="left">Streptococcus salivarius</td>
|
||
<td align="right">12</td>
|
||
<td align="right">0.6%</td>
|
||
<td align="right">1,782</td>
|
||
<td align="right">89.1%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">24</td>
|
||
<td align="left">Streptococcus agalactiae</td>
|
||
<td align="right">11</td>
|
||
<td align="right">0.6%</td>
|
||
<td align="right">1,793</td>
|
||
<td align="right">89.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">25</td>
|
||
<td align="left">Streptococcus species</td>
|
||
<td align="right">11</td>
|
||
<td align="right">0.6%</td>
|
||
<td align="right">1,804</td>
|
||
<td align="right">90.2%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">26</td>
|
||
<td align="left">Corynebacterium species</td>
|
||
<td align="right">10</td>
|
||
<td align="right">0.5%</td>
|
||
<td align="right">1,814</td>
|
||
<td align="right">90.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">27</td>
|
||
<td align="left">Streptococcus bovis</td>
|
||
<td align="right">10</td>
|
||
<td align="right">0.5%</td>
|
||
<td align="right">1,824</td>
|
||
<td align="right">91.2%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">28</td>
|
||
<td align="left">Clostridium difficile</td>
|
||
<td align="right">9</td>
|
||
<td align="right">0.5%</td>
|
||
<td align="right">1,833</td>
|
||
<td align="right">91.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">29</td>
|
||
<td align="left">Haemophilus influenzae</td>
|
||
<td align="right">8</td>
|
||
<td align="right">0.4%</td>
|
||
<td align="right">1,841</td>
|
||
<td align="right">92.1%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">30</td>
|
||
<td align="left">Candida albicans</td>
|
||
<td align="right">7</td>
|
||
<td align="right">0.4%</td>
|
||
<td align="right">1,848</td>
|
||
<td align="right">92.4%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">31</td>
|
||
<td align="left">Staphylococcus haemolyticus</td>
|
||
<td align="right">7</td>
|
||
<td align="right">0.4%</td>
|
||
<td align="right">1,855</td>
|
||
<td align="right">92.8%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">32</td>
|
||
<td align="left">Streptococcus constellatus</td>
|
||
<td align="right">7</td>
|
||
<td align="right">0.4%</td>
|
||
<td align="right">1,862</td>
|
||
<td align="right">93.1%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">33</td>
|
||
<td align="left">Candida glabrata</td>
|
||
<td align="right">6</td>
|
||
<td align="right">0.3%</td>
|
||
<td align="right">1,868</td>
|
||
<td align="right">93.4%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">34</td>
|
||
<td align="left">Citrobacter freundii</td>
|
||
<td align="right">6</td>
|
||
<td align="right">0.3%</td>
|
||
<td align="right">1,874</td>
|
||
<td align="right">93.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">35</td>
|
||
<td align="left">Corynebacterium striatum</td>
|
||
<td align="right">6</td>
|
||
<td align="right">0.3%</td>
|
||
<td align="right">1,880</td>
|
||
<td align="right">94.0%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">36</td>
|
||
<td align="left">Morganella morganii</td>
|
||
<td align="right">6</td>
|
||
<td align="right">0.3%</td>
|
||
<td align="right">1,886</td>
|
||
<td align="right">94.3%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">37</td>
|
||
<td align="left">Streptococcus anginosus</td>
|
||
<td align="right">6</td>
|
||
<td align="right">0.3%</td>
|
||
<td align="right">1,892</td>
|
||
<td align="right">94.6%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">38</td>
|
||
<td align="left">Streptococcus oralis</td>
|
||
<td align="right">6</td>
|
||
<td align="right">0.3%</td>
|
||
<td align="right">1,898</td>
|
||
<td align="right">94.9%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">39</td>
|
||
<td align="left">Acinetobacter baumannii</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,901</td>
|
||
<td align="right">95.1%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">40</td>
|
||
<td align="left">Acinetobacter species</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,904</td>
|
||
<td align="right">95.2%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">41</td>
|
||
<td align="left">Citrobacter koseri</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,907</td>
|
||
<td align="right">95.4%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">42</td>
|
||
<td align="left">Clostridium perfringens</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,910</td>
|
||
<td align="right">95.5%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">43</td>
|
||
<td align="left">Clostridium septicum</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,913</td>
|
||
<td align="right">95.7%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">44</td>
|
||
<td align="left">Enterobacter aerogenes</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,916</td>
|
||
<td align="right">95.8%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">45</td>
|
||
<td align="left">Gemella haemolysans</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,919</td>
|
||
<td align="right">96.0%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">46</td>
|
||
<td align="left">Micrococcus luteus</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,922</td>
|
||
<td align="right">96.1%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">47</td>
|
||
<td align="left">Micrococcus species</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,925</td>
|
||
<td align="right">96.3%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">48</td>
|
||
<td align="left">Salmonella enterica</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,928</td>
|
||
<td align="right">96.4%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">49</td>
|
||
<td align="left">Staphylococcus warneri</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,931</td>
|
||
<td align="right">96.6%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">50</td>
|
||
<td align="left">Streptococcus equi</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,934</td>
|
||
<td align="right">96.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">51</td>
|
||
<td align="left">Streptococcus group C</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,937</td>
|
||
<td align="right">96.9%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">52</td>
|
||
<td align="left">Streptococcus group G</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,940</td>
|
||
<td align="right">97.0%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">53</td>
|
||
<td align="left">Streptococcus intermedius</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,943</td>
|
||
<td align="right">97.2%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">54</td>
|
||
<td align="left">Streptococcus parasanguinis</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">1,946</td>
|
||
<td align="right">97.3%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">55</td>
|
||
<td align="left">Aerococcus urinae</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,948</td>
|
||
<td align="right">97.4%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">56</td>
|
||
<td align="left">Candida tropicalis</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,950</td>
|
||
<td align="right">97.5%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">57</td>
|
||
<td align="left">Citrobacter species</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,952</td>
|
||
<td align="right">97.6%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">58</td>
|
||
<td align="left">Enterococcus avium</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,954</td>
|
||
<td align="right">97.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">59</td>
|
||
<td align="left">Pantoea agglomerans</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,956</td>
|
||
<td align="right">97.8%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">60</td>
|
||
<td align="left">Pantoea species</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,958</td>
|
||
<td align="right">97.9%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">61</td>
|
||
<td align="left">Proteus vulgaris</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,960</td>
|
||
<td align="right">98.0%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">62</td>
|
||
<td align="left">Staphylococcus cohnii</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,962</td>
|
||
<td align="right">98.1%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">63</td>
|
||
<td align="left">Staphylococcus lugdunensis</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,964</td>
|
||
<td align="right">98.2%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">64</td>
|
||
<td align="left">Staphylococcus schleiferi</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,966</td>
|
||
<td align="right">98.3%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">65</td>
|
||
<td align="left">Stenotrophomonas maltophilia</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,968</td>
|
||
<td align="right">98.4%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">66</td>
|
||
<td align="left">Streptococcus mutans</td>
|
||
<td align="right">2</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,970</td>
|
||
<td align="right">98.5%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">67</td>
|
||
<td align="left">Actinomyces odontolyticus</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,971</td>
|
||
<td align="right">98.6%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">68</td>
|
||
<td align="left">Campylobacter jejuni</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,972</td>
|
||
<td align="right">98.6%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">69</td>
|
||
<td align="left">Candida lusitaniae</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,973</td>
|
||
<td align="right">98.7%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">70</td>
|
||
<td align="left">Clostridium novyi</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,974</td>
|
||
<td align="right">98.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">71</td>
|
||
<td align="left">Corynebacterium tuberculostearicum</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,975</td>
|
||
<td align="right">98.8%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">72</td>
|
||
<td align="left">Dermabacter hominis</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,976</td>
|
||
<td align="right">98.8%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">73</td>
|
||
<td align="left">Eikenella corrodens</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,977</td>
|
||
<td align="right">98.9%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">74</td>
|
||
<td align="left">Enterococcus casseliflavus</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,978</td>
|
||
<td align="right">98.9%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">75</td>
|
||
<td align="left">Escherichia vulneris</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,979</td>
|
||
<td align="right">99.0%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">76</td>
|
||
<td align="left">Fusobacterium species</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,980</td>
|
||
<td align="right">99.0%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">77</td>
|
||
<td align="left">Globicatella sanguinis</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,981</td>
|
||
<td align="right">99.1%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">78</td>
|
||
<td align="left">Granulicatella adiacens</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,982</td>
|
||
<td align="right">99.1%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">79</td>
|
||
<td align="left">Haemophilus parainfluenzae</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,983</td>
|
||
<td align="right">99.2%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">80</td>
|
||
<td align="left">Hafnia alvei</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,984</td>
|
||
<td align="right">99.2%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">81</td>
|
||
<td align="left">Lactobacillus delbrueckii</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,985</td>
|
||
<td align="right">99.3%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">82</td>
|
||
<td align="left">Leuconostoc species</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,986</td>
|
||
<td align="right">99.3%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">83</td>
|
||
<td align="left">Listeria monocytogenes</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,987</td>
|
||
<td align="right">99.4%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">84</td>
|
||
<td align="left">Neisseria meningitidis</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,988</td>
|
||
<td align="right">99.4%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">85</td>
|
||
<td align="left">Neisseria sicca</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,989</td>
|
||
<td align="right">99.5%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">86</td>
|
||
<td align="left">Paenibacillus durus</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,990</td>
|
||
<td align="right">99.5%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">87</td>
|
||
<td align="left">Propionibacterium acnes</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,991</td>
|
||
<td align="right">99.6%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">88</td>
|
||
<td align="left">Proteus penneri</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,992</td>
|
||
<td align="right">99.6%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">89</td>
|
||
<td align="left">Rothia mucilaginosa</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,993</td>
|
||
<td align="right">99.7%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">90</td>
|
||
<td align="left">Sphingobacterium spiritivorum</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,994</td>
|
||
<td align="right">99.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">91</td>
|
||
<td align="left">Sphingomonas paucimobilis</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,995</td>
|
||
<td align="right">99.8%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">92</td>
|
||
<td align="left">Streptococcus equinus</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,996</td>
|
||
<td align="right">99.8%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">93</td>
|
||
<td align="left">Streptococcus gordonii</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,997</td>
|
||
<td align="right">99.9%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">94</td>
|
||
<td align="left">Streptococcus infantarius</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,998</td>
|
||
<td align="right">99.9%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">95</td>
|
||
<td align="left">Streptococcus sanguinis</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">1,999</td>
|
||
<td align="right">100.0%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">96</td>
|
||
<td align="left">Veillonella parvula</td>
|
||
<td align="right">1</td>
|
||
<td align="right">0.1%</td>
|
||
<td align="right">2,000</td>
|
||
<td align="right">100.0%</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div id="frequencies-of-numeric-values" class="section level2">
|
||
<h2 class="hasAnchor">
|
||
<a href="#frequencies-of-numeric-values" class="anchor"></a>Frequencies of numeric values</h2>
|
||
<p>Frequency tables can be created of any input.</p>
|
||
<p>In case of numeric values (like integers, doubles, etc.) additional descriptive statistics will be calculated and shown into the header. When creating frequency tables automatically (like here in markdown), add <code>header = TRUE</code> to also show the header in markdown reports:</p>
|
||
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1"><span class="co"># get age distribution of unique patients</span></a>
|
||
<a class="sourceLine" id="cb6-2" data-line-number="2">septic_patients <span class="op">%>%</span><span class="st"> </span></a>
|
||
<a class="sourceLine" id="cb6-3" data-line-number="3"><span class="st"> </span><span class="kw">distinct</span>(patient_id, <span class="dt">.keep_all =</span> <span class="ot">TRUE</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||
<a class="sourceLine" id="cb6-4" data-line-number="4"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(age, <span class="dt">nmax =</span> <span class="dv">5</span>, <span class="dt">header =</span> <span class="ot">TRUE</span>)</a></code></pre></div>
|
||
<p><strong>Frequency table of <code>age</code></strong></p>
|
||
<p>Class: numeric</p>
|
||
<p>Length: 981 (of which NA: 0 = 0.00%)</p>
|
||
<p>Unique: 73</p>
|
||
<p>Mean: 71</p>
|
||
<p>Std. dev.: 14 (CV: 0.2, MAD: 13)</p>
|
||
<p>Five-Num: 14 | 63 | 74 | 82 | 97 (IQR: 19, CQV: 0.13)</p>
|
||
<p>Outliers: 15 (unique count: 12)</p>
|
||
<table class="table">
|
||
<thead><tr class="header">
|
||
<th align="left"></th>
|
||
<th align="right">Item</th>
|
||
<th align="right">Count</th>
|
||
<th align="right">Percent</th>
|
||
<th align="right">Cum. Count</th>
|
||
<th align="right">Cum. Percent</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td align="left">1</td>
|
||
<td align="right">83</td>
|
||
<td align="right">44</td>
|
||
<td align="right">4.5%</td>
|
||
<td align="right">44</td>
|
||
<td align="right">4.5%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">2</td>
|
||
<td align="right">76</td>
|
||
<td align="right">43</td>
|
||
<td align="right">4.4%</td>
|
||
<td align="right">87</td>
|
||
<td align="right">8.9%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">3</td>
|
||
<td align="right">75</td>
|
||
<td align="right">37</td>
|
||
<td align="right">3.8%</td>
|
||
<td align="right">124</td>
|
||
<td align="right">12.6%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">4</td>
|
||
<td align="right">82</td>
|
||
<td align="right">33</td>
|
||
<td align="right">3.4%</td>
|
||
<td align="right">157</td>
|
||
<td align="right">16.0%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">5</td>
|
||
<td align="right">78</td>
|
||
<td align="right">32</td>
|
||
<td align="right">3.3%</td>
|
||
<td align="right">189</td>
|
||
<td align="right">19.3%</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>(omitted 68 entries, n = 792 [80.7%])</p>
|
||
<p>So the following properties are determined, where <code>NA</code> values are always ignored:</p>
|
||
<ul>
|
||
<li><p><strong>Mean</strong></p></li>
|
||
<li><p><strong>Standard deviation</strong></p></li>
|
||
<li><p><strong>Coefficient of variation</strong> (CV), the standard deviation divided by the mean</p></li>
|
||
<li><p><strong>Five numbers of Tukey</strong> (min, Q1, median, Q3, max)</p></li>
|
||
<li><p><strong>Coefficient of quartile variation</strong> (CQV, sometimes called coefficient of dispersion), calculated as (Q3 - Q1) / (Q3 + Q1) using quantile with <code>type = 6</code> as quantile algorithm to comply with SPSS standards</p></li>
|
||
<li><p><strong>Outliers</strong> (total count and unique count)</p></li>
|
||
</ul>
|
||
<p>So for example, the above frequency table quickly shows the median age of patients being 74.</p>
|
||
</div>
|
||
<div id="frequencies-of-factors" class="section level2">
|
||
<h2 class="hasAnchor">
|
||
<a href="#frequencies-of-factors" class="anchor"></a>Frequencies of factors</h2>
|
||
<p>Frequencies of factors can be sorted on factor level instead of item count with the <code>sort.count</code> parameter.</p>
|
||
<p>Default behaviour:</p>
|
||
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">septic_patients <span class="op">%>%</span></a>
|
||
<a class="sourceLine" id="cb7-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(hospital_id)</a></code></pre></div>
|
||
<p><strong>Frequency table of <code>hospital_id</code></strong></p>
|
||
<table class="table">
|
||
<thead><tr class="header">
|
||
<th align="left"></th>
|
||
<th align="left">Item</th>
|
||
<th align="right">Count</th>
|
||
<th align="right">Percent</th>
|
||
<th align="right">Cum. Count</th>
|
||
<th align="right">Cum. Percent</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td align="left">1</td>
|
||
<td align="left">D</td>
|
||
<td align="right">762</td>
|
||
<td align="right">38.1%</td>
|
||
<td align="right">762</td>
|
||
<td align="right">38.1%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">2</td>
|
||
<td align="left">B</td>
|
||
<td align="right">663</td>
|
||
<td align="right">33.2%</td>
|
||
<td align="right">1,425</td>
|
||
<td align="right">71.3%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">3</td>
|
||
<td align="left">A</td>
|
||
<td align="right">321</td>
|
||
<td align="right">16.1%</td>
|
||
<td align="right">1,746</td>
|
||
<td align="right">87.3%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">4</td>
|
||
<td align="left">C</td>
|
||
<td align="right">254</td>
|
||
<td align="right">12.7%</td>
|
||
<td align="right">2,000</td>
|
||
<td align="right">100.0%</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>Sorting on item instead of count:</p>
|
||
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1">septic_patients <span class="op">%>%</span></a>
|
||
<a class="sourceLine" id="cb8-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(hospital_id, <span class="dt">sort.count =</span> <span class="ot">FALSE</span>)</a></code></pre></div>
|
||
<p><strong>Frequency table of <code>hospital_id</code></strong></p>
|
||
<table class="table">
|
||
<thead><tr class="header">
|
||
<th align="left"></th>
|
||
<th align="left">Item</th>
|
||
<th align="right">Count</th>
|
||
<th align="right">Percent</th>
|
||
<th align="right">Cum. Count</th>
|
||
<th align="right">Cum. Percent</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td align="left">1</td>
|
||
<td align="left">A</td>
|
||
<td align="right">321</td>
|
||
<td align="right">16.1%</td>
|
||
<td align="right">321</td>
|
||
<td align="right">16.1%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">2</td>
|
||
<td align="left">B</td>
|
||
<td align="right">663</td>
|
||
<td align="right">33.2%</td>
|
||
<td align="right">984</td>
|
||
<td align="right">49.2%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">3</td>
|
||
<td align="left">C</td>
|
||
<td align="right">254</td>
|
||
<td align="right">12.7%</td>
|
||
<td align="right">1,238</td>
|
||
<td align="right">61.9%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">4</td>
|
||
<td align="left">D</td>
|
||
<td align="right">762</td>
|
||
<td align="right">38.1%</td>
|
||
<td align="right">2,000</td>
|
||
<td align="right">100.0%</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>All classes will be printed into the header. Variables with the new <code>rsi</code> class of this AMR package are actually ordered factors and have three classes (look at <code>Class</code> in the header):</p>
|
||
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" data-line-number="1">septic_patients <span class="op">%>%</span></a>
|
||
<a class="sourceLine" id="cb9-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(amox, <span class="dt">header =</span> <span class="ot">TRUE</span>)</a></code></pre></div>
|
||
<p><strong>Frequency table of <code>amox</code></strong></p>
|
||
<p>Class: factor > ordered > rsi (numeric)</p>
|
||
<p>Levels: S < I < R</p>
|
||
<p>Length: 2,000 (of which NA: 828 = 41.40%)</p>
|
||
<p>Unique: 3</p>
|
||
<table class="table">
|
||
<thead><tr class="header">
|
||
<th align="left"></th>
|
||
<th align="left">Item</th>
|
||
<th align="right">Count</th>
|
||
<th align="right">Percent</th>
|
||
<th align="right">Cum. Count</th>
|
||
<th align="right">Cum. Percent</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td align="left">1</td>
|
||
<td align="left">R</td>
|
||
<td align="right">683</td>
|
||
<td align="right">58.3%</td>
|
||
<td align="right">683</td>
|
||
<td align="right">58.3%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">2</td>
|
||
<td align="left">S</td>
|
||
<td align="right">486</td>
|
||
<td align="right">41.5%</td>
|
||
<td align="right">1,169</td>
|
||
<td align="right">99.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">3</td>
|
||
<td align="left">I</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.3%</td>
|
||
<td align="right">1,172</td>
|
||
<td align="right">100.0%</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div id="frequencies-of-dates" class="section level2">
|
||
<h2 class="hasAnchor">
|
||
<a href="#frequencies-of-dates" class="anchor"></a>Frequencies of dates</h2>
|
||
<p>Frequencies of dates will show the oldest and newest date in the data, and the amount of days between them:</p>
|
||
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb10-1" data-line-number="1">septic_patients <span class="op">%>%</span></a>
|
||
<a class="sourceLine" id="cb10-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(date, <span class="dt">nmax =</span> <span class="dv">5</span>, <span class="dt">header =</span> <span class="ot">TRUE</span>)</a></code></pre></div>
|
||
<p><strong>Frequency table of <code>date</code></strong></p>
|
||
<p>Class: Date (numeric)</p>
|
||
<p>Length: 2,000 (of which NA: 0 = 0.00%)</p>
|
||
<p>Unique: 1,140</p>
|
||
<p>Oldest: 2 januari 2002</p>
|
||
<p>Newest: 28 december 2017 (+5,839)</p>
|
||
<p>Median: 31 juli 2009 (~47%)</p>
|
||
<table class="table">
|
||
<thead><tr class="header">
|
||
<th align="left"></th>
|
||
<th align="left">Item</th>
|
||
<th align="right">Count</th>
|
||
<th align="right">Percent</th>
|
||
<th align="right">Cum. Count</th>
|
||
<th align="right">Cum. Percent</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td align="left">1</td>
|
||
<td align="left">2016-05-21</td>
|
||
<td align="right">10</td>
|
||
<td align="right">0.5%</td>
|
||
<td align="right">10</td>
|
||
<td align="right">0.5%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">2</td>
|
||
<td align="left">2004-11-15</td>
|
||
<td align="right">8</td>
|
||
<td align="right">0.4%</td>
|
||
<td align="right">18</td>
|
||
<td align="right">0.9%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">3</td>
|
||
<td align="left">2013-07-29</td>
|
||
<td align="right">8</td>
|
||
<td align="right">0.4%</td>
|
||
<td align="right">26</td>
|
||
<td align="right">1.3%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">4</td>
|
||
<td align="left">2017-06-12</td>
|
||
<td align="right">8</td>
|
||
<td align="right">0.4%</td>
|
||
<td align="right">34</td>
|
||
<td align="right">1.7%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">5</td>
|
||
<td align="left">2015-11-19</td>
|
||
<td align="right">7</td>
|
||
<td align="right">0.4%</td>
|
||
<td align="right">41</td>
|
||
<td align="right">2.1%</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>(omitted 1,135 entries, n = 1,959 [98.0%])</p>
|
||
</div>
|
||
<div id="assigning-a-frequency-table-to-an-object" class="section level2">
|
||
<h2 class="hasAnchor">
|
||
<a href="#assigning-a-frequency-table-to-an-object" class="anchor"></a>Assigning a frequency table to an object</h2>
|
||
<p>A frequency table is actually a regular <code>data.frame</code>, with the exception that it contains an additional class.</p>
|
||
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb11-1" data-line-number="1">my_df <-<span class="st"> </span>septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(age)</a></code></pre></div>
|
||
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/class">class</a></span>(my_df)</a>
|
||
<a class="sourceLine" id="cb12-2" data-line-number="2">[<span class="dv">1</span>] <span class="st">"frequency_tbl"</span> <span class="st">"data.frame"</span> </a></code></pre></div>
|
||
<p>Because of this additional class, a frequency table prints like the examples above. But the object itself contains the complete table without a row limitation:</p>
|
||
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb13-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/dim">dim</a></span>(my_df)</a>
|
||
<a class="sourceLine" id="cb13-2" data-line-number="2">[<span class="dv">1</span>] <span class="dv">74</span> <span class="dv">5</span></a></code></pre></div>
|
||
</div>
|
||
<div id="additional-parameters" class="section level2">
|
||
<h2 class="hasAnchor">
|
||
<a href="#additional-parameters" class="anchor"></a>Additional parameters</h2>
|
||
<div id="parameter-na-rm" class="section level3">
|
||
<h3 class="hasAnchor">
|
||
<a href="#parameter-na-rm" class="anchor"></a>Parameter <code>na.rm</code>
|
||
</h3>
|
||
<p>With the <code>na.rm</code> parameter (defaults to <code>TRUE</code>, but they will always be shown into the header), you can include <code>NA</code> values in the frequency table:</p>
|
||
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb14-1" data-line-number="1">septic_patients <span class="op">%>%</span></a>
|
||
<a class="sourceLine" id="cb14-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(amox, <span class="dt">na.rm =</span> <span class="ot">FALSE</span>)</a>
|
||
<a class="sourceLine" id="cb14-3" data-line-number="3">Warning<span class="op">:</span><span class="st"> </span>Factor <span class="st">`</span><span class="dt">item</span><span class="st">`</span> contains implicit <span class="ot">NA</span>, consider using</a>
|
||
<a class="sourceLine" id="cb14-4" data-line-number="4"><span class="st">`</span><span class="dt">forcats::fct_explicit_na</span><span class="st">`</span></a></code></pre></div>
|
||
<p><strong>Frequency table of <code>amox</code></strong></p>
|
||
<table class="table">
|
||
<thead><tr class="header">
|
||
<th align="left"></th>
|
||
<th align="left">Item</th>
|
||
<th align="right">Count</th>
|
||
<th align="right">Percent</th>
|
||
<th align="right">Cum. Count</th>
|
||
<th align="right">Cum. Percent</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td align="left">1</td>
|
||
<td align="left"><na></na></td>
|
||
<td align="right">828</td>
|
||
<td align="right">41.4%</td>
|
||
<td align="right">828</td>
|
||
<td align="right">41.4%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">2</td>
|
||
<td align="left">R</td>
|
||
<td align="right">683</td>
|
||
<td align="right">34.2%</td>
|
||
<td align="right">1,511</td>
|
||
<td align="right">75.6%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">3</td>
|
||
<td align="left">S</td>
|
||
<td align="right">486</td>
|
||
<td align="right">24.3%</td>
|
||
<td align="right">1,997</td>
|
||
<td align="right">99.9%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">4</td>
|
||
<td align="left">I</td>
|
||
<td align="right">3</td>
|
||
<td align="right">0.2%</td>
|
||
<td align="right">2,000</td>
|
||
<td align="right">100.0%</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div id="parameter-row-names" class="section level3">
|
||
<h3 class="hasAnchor">
|
||
<a href="#parameter-row-names" class="anchor"></a>Parameter <code>row.names</code>
|
||
</h3>
|
||
<p>The default frequency tables shows row indices. To remove them, use <code>row.names = FALSE</code>:</p>
|
||
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb15-1" data-line-number="1">septic_patients <span class="op">%>%</span></a>
|
||
<a class="sourceLine" id="cb15-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(hospital_id, <span class="dt">row.names =</span> <span class="ot">FALSE</span>)</a></code></pre></div>
|
||
<p><strong>Frequency table of <code>hospital_id</code></strong></p>
|
||
<table class="table">
|
||
<thead><tr class="header">
|
||
<th align="left">Item</th>
|
||
<th align="right">Count</th>
|
||
<th align="right">Percent</th>
|
||
<th align="right">Cum. Count</th>
|
||
<th align="right">Cum. Percent</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td align="left">D</td>
|
||
<td align="right">762</td>
|
||
<td align="right">38.1%</td>
|
||
<td align="right">762</td>
|
||
<td align="right">38.1%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">B</td>
|
||
<td align="right">663</td>
|
||
<td align="right">33.2%</td>
|
||
<td align="right">1,425</td>
|
||
<td align="right">71.3%</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td align="left">A</td>
|
||
<td align="right">321</td>
|
||
<td align="right">16.1%</td>
|
||
<td align="right">1,746</td>
|
||
<td align="right">87.3%</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td align="left">C</td>
|
||
<td align="right">254</td>
|
||
<td align="right">12.7%</td>
|
||
<td align="right">2,000</td>
|
||
<td align="right">100.0%</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<hr>
|
||
<p>AMR, (c) 2018, <a href="https://msberends.gitlab.io/AMR,https://gitlab.com/msberends/AMR" class="uri">https://msberends.gitlab.io/AMR,https://gitlab.com/msberends/AMR</a></p>
|
||
<p>Licensed under the <a href="https://gitlab.com/msberends/AMR/blob/master/LICENSE">GNU General Public License v2.0</a>.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||
<div id="tocnav">
|
||
<h2 class="hasAnchor">
|
||
<a href="#tocnav" class="anchor"></a>Contents</h2>
|
||
<ul class="nav nav-pills nav-stacked">
|
||
<li><a href="#introduction">Introduction</a></li>
|
||
<li><a href="#frequencies-of-one-variable">Frequencies of one variable</a></li>
|
||
<li><a href="#frequencies-of-more-than-one-variable">Frequencies of more than one variable</a></li>
|
||
<li><a href="#frequencies-of-numeric-values">Frequencies of numeric values</a></li>
|
||
<li><a href="#frequencies-of-factors">Frequencies of factors</a></li>
|
||
<li><a href="#frequencies-of-dates">Frequencies of dates</a></li>
|
||
<li><a href="#assigning-a-frequency-table-to-an-object">Assigning a frequency table to an object</a></li>
|
||
<li><a href="#additional-parameters">Additional parameters</a></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
|
||
<footer><div class="copyright">
|
||
<p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/c.glasner/">Corinna Glasner</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/">Alex W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/">Bhanu N. M. Sinha</a>.</p>
|
||
</div>
|
||
|
||
<div class="pkgdown">
|
||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||
</div>
|
||
</footer>
|
||
</div>
|
||
|
||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.js" integrity="sha256-GKvGqXDznoRYHCwKXGnuchvKSwmx9SRMrZOTh2g4Sb0=" crossorigin="anonymous"></script><script>
|
||
docsearch({
|
||
|
||
|
||
apiKey: 'f737050abfd4d726c63938e18f8c496e',
|
||
indexName: 'amr',
|
||
inputSelector: 'input#search-input.form-control',
|
||
transformData: function(hits) {
|
||
return hits.map(function (hit) {
|
||
hit.url = updateHitURL(hit);
|
||
return hit;
|
||
});
|
||
}
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|