<metaproperty="og:description"content="Create a frequency table of a vector with items or a data frame. Supports quasiquotation and markdown for reports. top_freq can be used to get the top/bottom n items of a frequency table, with counts as names."/>
<p>Create a frequency table of a vector with items or a data frame. Supports quasiquotation and markdown for reports. <code>top_freq</code> can be used to get the top/bottom <em>n</em> items of a frequency table, with counts as names.</p>
<td><p>vector of any class or a <code><ahref='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></code>, <code>tibble</code> (may contain a grouping variable) or <code><ahref='https://www.rdocumentation.org/packages/base/topics/table'>table</a></code></p></td>
</tr>
<tr>
<th>...</th>
<td><p>up to nine different columns of <code>x</code> when <code>x</code> is a <code>data.frame</code> or <code>tibble</code>, to calculate frequencies from - see Examples</p></td>
</tr>
<tr>
<th>sort.count</th>
<td><p>sort on count, i.e. frequencies. This will be <code>TRUE</code> at default for everything except when using grouping variables.</p></td>
</tr>
<tr>
<th>nmax</th>
<td><p>number of row to print. The default, <code>15</code>, uses <code><ahref='https://www.rdocumentation.org/packages/base/topics/options'>getOption</a>("max.print.freq")</code>. Use <code>nmax = 0</code>, <code>nmax = Inf</code>, <code>nmax = NULL</code> or <code>nmax = NA</code> to print all rows.</p></td>
</tr>
<tr>
<th>na.rm</th>
<td><p>a logical value indicating whether <code>NA</code> values should be removed from the frequency table. The header (if set) will always print the amount of <code>NA</code>s.</p></td>
</tr>
<tr>
<th>row.names</th>
<td><p>a logical value indicating whether row indices should be printed as <code>1:nrow(x)</code></p></td>
</tr>
<tr>
<th>markdown</th>
<td><p>a logical value indicating whether the frequency table should be printed in markdown format. This will print all rows (except when <code>nmax</code> is defined) and is default behaviour in non-interactive R sessions (like when knitting RMarkdown files).</p></td>
</tr>
<tr>
<th>digits</th>
<td><p>how many significant digits are to be used for numeric values in the header (not for the items themselves, that depends on <code><ahref='https://www.rdocumentation.org/packages/base/topics/options'>getOption</a>("digits")</code>)</p></td>
</tr>
<tr>
<th>quote</th>
<td><p>a logical value indicating whether or not strings should be printed with surrounding quotes</p></td>
</tr>
<tr>
<th>header</th>
<td><p>a logical value indicating whether an informative header should be printed</p></td>
</tr>
<tr>
<th>title</th>
<td><p>text to show above frequency table, at default to tries to coerce from the variables passed to <code>x</code></p></td>
</tr>
<tr>
<th>na</th>
<td><p>a character string to should be used to show empty (<code>NA</code>) values (only useful when <code>na.rm = FALSE</code>)</p></td>
</tr>
<tr>
<th>droplevels</th>
<td><p>a logical value indicating whether in factors empty levels should be dropped</p></td>
</tr>
<tr>
<th>sep</th>
<td><p>a character string to separate the terms when selecting multiple columns</p></td>
</tr>
<tr>
<th>decimal.mark</th>
<td><p><!-- % -->
used for prettying (longish) numerical and complex sequences.
Passed to <code><ahref='https://www.rdocumentation.org/packages/base/topics/formatc'>prettyNum</a></code>: that help page explains the details.</p></td>
</tr>
<tr>
<th>big.mark</th>
<td><p><!-- % -->
used for prettying (longish) numerical and complex sequences.
Passed to <code><ahref='https://www.rdocumentation.org/packages/base/topics/formatc'>prettyNum</a></code>: that help page explains the details.</p></td>
</tr>
<tr>
<th>f</th>
<td><p>a frequency table</p></td>
</tr>
<tr>
<th>n</th>
<td><p>number of top <em>n</em> items to return, use -n for the bottom <em>n</em> items. It will include more than <code>n</code> rows if there are ties.</p></td>
</tr>
<tr>
<th>property</th>
<td><p>property in header to return this value directly</p></td>
<p>A <code>data.frame</code> (with an additional class <code>"frequency_tbl"</code>) with five columns: <code>item</code>, <code>count</code>, <code>percent</code>, <code>cum_count</code> and <code>cum_percent</code>.</p>
<p>Frequency tables (or frequency distributions) are summaries of the distribution of values in a sample. With the `freq` function, you can create univariate frequency tables. Multiple variables will be pasted into one variable, so it forces a univariate distribution. This package also has a vignette available to explain the use of this function further, run <code><ahref='https://www.rdocumentation.org/packages/utils/topics/browseVignettes'>browseVignettes("AMR")</a></code> to read it.</p>
<p>For numeric values of any class, these additional values will all be calculated with <code>na.rm = TRUE</code> and shown into the header:</p><ul>
<li><p>Mean, using <code><ahref='https://www.rdocumentation.org/packages/base/topics/mean'>mean</a></code></p></li>
<li><p>Standard Deviation, using <code><ahref='https://www.rdocumentation.org/packages/stats/topics/sd'>sd</a></code></p></li>
<li><p>Coefficient of Variation (CV), the standard deviation divided by the mean</p></li>
<li><p>Mean Absolute Deviation (MAD), using <code><ahref='https://www.rdocumentation.org/packages/stats/topics/mad'>mad</a></code></p></li>
<li><p>Tukey Five-Number Summaries (minimum, Q1, median, Q3, maximum), using <code><ahref='https://www.rdocumentation.org/packages/stats/topics/fivenum'>fivenum</a></code></p></li>
<li><p>Interquartile Range (IQR) calculated as <code>Q3 - Q1</code> using the Tukey Five-Number Summaries, i.e. <strong>not</strong> using the <code><ahref='https://www.rdocumentation.org/packages/stats/topics/quantile'>quantile</a></code> function</p></li>
<li><p>Coefficient of Quartile Variation (CQV, sometimes called coefficient of dispersion), calculated as <code>(Q3 - Q1) / (Q3 + Q1)</code> using the Tukey Five-Number Summaries</p></li>
<li><p>Outliers (total count and unique count), using <code><ahref='https://www.rdocumentation.org/packages/grDevices/topics/boxplot.stats'>boxplot.stats</a></code></p></li>
</ul>
<p>For dates and times of any class, these additional values will be calculated with <code>na.rm = TRUE</code> and shown into the header:</p><ul>
<li><p>Oldest, using <code><ahref='https://www.rdocumentation.org/packages/base/topics/Extremes'>min</a></code></p></li>
<li><p>Newest, using <code><ahref='https://www.rdocumentation.org/packages/base/topics/Extremes'>max</a></code>, with difference between newest and oldest</p></li>
<li><p>Median, using <code><ahref='https://www.rdocumentation.org/packages/stats/topics/median'>median</a></code>, with percentage since oldest</p></li>
</ul>
<p>In factors, all factor levels that are not existing in the input data will be dropped.</p>
<p>The function <code>top_freq</code> uses <code><ahref='http://dplyr.tidyverse.org/reference/top_n.html'>top_n</a></code> internally and will include more than <code>n</code> rows if there are ties.</p>
<p>Developed by <ahref='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <ahref='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <ahref='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>, <ahref='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <ahref='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>.</p>
</div>
<divclass="pkgdown">
<p>Site built with <ahref="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>