(v0.7.1.9015) Remove freq()

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-07-29 13:33:48 +02:00
parent 9ac5a34b36
commit 240f03a672
75 changed files with 668 additions and 2877 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 0.7.1.9014
Date: 2019-07-16
Version: 0.7.1.9015
Date: 2019-07-29
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(
@ -45,6 +45,7 @@ Depends:
R (>= 3.1.0)
Imports:
backports,
clean,
crayon (>= 1.3.0),
data.table (>= 1.9.0),
dplyr (>= 0.7.0),
@ -59,7 +60,6 @@ Suggests:
covr (>= 3.0.1),
curl,
readxl,
rmarkdown,
rstudioapi,
rvest (>= 0.3.2),
testthat (>= 1.0.2),

View File

@ -1,7 +1,6 @@
# Generated by roxygen2: do not edit by hand
S3method(as.data.frame,ab)
S3method(as.data.frame,freq)
S3method(as.data.frame,mo)
S3method(as.double,mic)
S3method(as.integer,mic)
@ -10,28 +9,21 @@ S3method(as.rsi,data.frame)
S3method(as.rsi,default)
S3method(as.rsi,disk)
S3method(as.rsi,mic)
S3method(as.vector,freq)
S3method(as_tibble,freq)
S3method(barplot,mic)
S3method(barplot,rsi)
S3method(boxplot,freq)
S3method(diff,freq)
S3method(droplevels,mic)
S3method(droplevels,rsi)
S3method(format,freq)
S3method(hist,freq)
S3method(freq,mo)
S3method(freq,rsi)
S3method(kurtosis,data.frame)
S3method(kurtosis,default)
S3method(kurtosis,matrix)
S3method(plot,freq)
S3method(plot,mic)
S3method(plot,resistance_predict)
S3method(plot,rsi)
S3method(print,ab)
S3method(print,catalogue_of_life_version)
S3method(print,disk)
S3method(print,freq)
S3method(print,frequency_tbl)
S3method(print,mic)
S3method(print,mo)
S3method(print,mo_renamed)
@ -39,7 +31,6 @@ S3method(print,mo_uncertainties)
S3method(print,rsi)
S3method(pull,ab)
S3method(pull,mo)
S3method(select,freq)
S3method(skewness,data.frame)
S3method(skewness,default)
S3method(skewness,matrix)
@ -98,8 +89,6 @@ export(filter_glycopeptides)
export(filter_macrolides)
export(filter_tetracyclines)
export(first_isolate)
export(freq)
export(frequency_tbl)
export(full_join_microorganisms)
export(g.test)
export(geom_rsi)
@ -108,7 +97,6 @@ export(get_mo_source)
export(ggplot_rsi)
export(ggplot_rsi_predict)
export(guess_ab_col)
export(header)
export(inner_join_microorganisms)
export(is.ab)
export(is.disk)
@ -171,35 +159,26 @@ export(semi_join_microorganisms)
export(set_mo_source)
export(skewness)
export(theme_rsi)
export(top_freq)
exportMethods(as.data.frame.ab)
exportMethods(as.data.frame.freq)
exportMethods(as.data.frame.mo)
exportMethods(as.double.mic)
exportMethods(as.integer.mic)
exportMethods(as.numeric.mic)
exportMethods(as.vector.freq)
exportMethods(as_tibble.freq)
exportMethods(barplot.mic)
exportMethods(barplot.rsi)
exportMethods(boxplot.freq)
exportMethods(diff.freq)
exportMethods(droplevels.mic)
exportMethods(droplevels.rsi)
exportMethods(format.freq)
exportMethods(hist.freq)
exportMethods(freq.mo)
exportMethods(freq.rsi)
exportMethods(kurtosis)
exportMethods(kurtosis.data.frame)
exportMethods(kurtosis.default)
exportMethods(kurtosis.matrix)
exportMethods(plot.freq)
exportMethods(plot.mic)
exportMethods(plot.rsi)
exportMethods(print.ab)
exportMethods(print.catalogue_of_life_version)
exportMethods(print.disk)
exportMethods(print.freq)
exportMethods(print.frequency_tbl)
exportMethods(print.mic)
exportMethods(print.mo)
exportMethods(print.mo_renamed)
@ -209,7 +188,6 @@ exportMethods(pull.ab)
exportMethods(pull.mo)
exportMethods(scale_type.ab)
exportMethods(scale_type.mo)
exportMethods(select.freq)
exportMethods(skewness)
exportMethods(skewness.data.frame)
exportMethods(skewness.default)
@ -217,6 +195,7 @@ exportMethods(skewness.matrix)
exportMethods(summary.mic)
exportMethods(summary.mo)
exportMethods(summary.rsi)
importFrom(clean,freq)
importFrom(crayon,bgGreen)
importFrom(crayon,bgRed)
importFrom(crayon,bgYellow)
@ -232,7 +211,6 @@ importFrom(crayon,strip_style)
importFrom(crayon,underline)
importFrom(crayon,white)
importFrom(crayon,yellow)
importFrom(data.table,address)
importFrom(data.table,as.data.table)
importFrom(data.table,data.table)
importFrom(data.table,setkey)
@ -241,18 +219,14 @@ importFrom(dplyr,all_vars)
importFrom(dplyr,any_vars)
importFrom(dplyr,arrange)
importFrom(dplyr,arrange_at)
importFrom(dplyr,as_tibble)
importFrom(dplyr,between)
importFrom(dplyr,bind_cols)
importFrom(dplyr,bind_rows)
importFrom(dplyr,case_when)
importFrom(dplyr,desc)
importFrom(dplyr,distinct)
importFrom(dplyr,everything)
importFrom(dplyr,filter)
importFrom(dplyr,filter_all)
importFrom(dplyr,filter_at)
importFrom(dplyr,full_join)
importFrom(dplyr,funs)
importFrom(dplyr,group_by)
importFrom(dplyr,group_by_at)
@ -275,35 +249,23 @@ importFrom(dplyr,slice)
importFrom(dplyr,summarise)
importFrom(dplyr,summarise_if)
importFrom(dplyr,tibble)
importFrom(dplyr,top_n)
importFrom(dplyr,transmute)
importFrom(dplyr,ungroup)
importFrom(dplyr,vars)
importFrom(grDevices,boxplot.stats)
importFrom(graphics,arrows)
importFrom(graphics,axis)
importFrom(graphics,barplot)
importFrom(graphics,boxplot)
importFrom(graphics,hist)
importFrom(graphics,par)
importFrom(graphics,plot)
importFrom(graphics,points)
importFrom(graphics,text)
importFrom(hms,is.hms)
importFrom(knitr,kable)
importFrom(microbenchmark,microbenchmark)
importFrom(rlang,as_label)
importFrom(rlang,enquos)
importFrom(rlang,eval_tidy)
importFrom(scales,percent)
importFrom(stats,complete.cases)
importFrom(stats,fivenum)
importFrom(stats,glm)
importFrom(stats,lm)
importFrom(stats,mad)
importFrom(stats,pchisq)
importFrom(stats,predict)
importFrom(stats,sd)
importFrom(utils,browseURL)
importFrom(utils,browseVignettes)
importFrom(utils,installed.packages)

View File

@ -1,4 +1,7 @@
# AMR 0.7.1.9014
# AMR 0.7.1.9015
### Breaking
* Function `freq()` has moved to a new package, [`clean`](https://github.com/msberends/clean) ([CRAN link](https://cran.r-project.org/package=clean)). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. We decided to create a new package for data cleaning and checking and it perfectly fits the `freq()` function. The [`clean`](https://github.com/msberends/clean) package is available on CRAN and will be installed automatically when updating the `AMR` package, that now imports it. In a later stage, the `skewness()` and `kurtosis()` functions will be moved to the `clean` package too.
### New
* Additional way to calculate co-resistance, i.e. when using multiple antibiotics as input for `portion_*` functions or `count_*` functions. This can be used to determine the empiric susceptibily of a combination therapy. A new parameter `only_all_tested` (**which defaults to `FALSE`**) replaces the old `also_single_tested` and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the `portion` and `count` help pages), where the %SI is being determined:

1268
R/freq.R

File diff suppressed because it is too large Load Diff

View File

@ -62,12 +62,6 @@ navbar:
- text: "Get properties of an antibiotic"
icon: "fa-capsules"
href: "reference/ab_property.html" # reference instead of article
- text: "Create frequency tables"
icon: "fa-sort-amount-down"
href: "articles/freq.html"
# - text: "Use the G-test"
# icon: "fa-clipboard-check"
# href: "reference/g.test.html" # reference instead of article
- text: "Other: benchmarks"
icon: "fa-shipping-fast"
href: "articles/benchmarks.html"
@ -130,13 +124,12 @@ reference:
- title: "Analysing your data"
desc: >
Functions for conducting AMR analysis, like counting isolates, calculating
resistance or susceptibility, creating frequency tables or make plots.
resistance or susceptibility, or make plots.
contents:
- "`availability`"
- "`count`"
- "`portion`"
- "`filter_ab_class`"
- "`freq`"
- "`g.test`"
- "`ggplot_rsi`"
- "`kurtosis`"

View File

@ -78,7 +78,7 @@
</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="Latest development version">0.7.1.9014</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -156,13 +156,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View File

@ -40,7 +40,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -118,13 +118,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -192,7 +185,7 @@
<h1>How to apply EUCAST rules</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">10 July 2019</h4>
<h4 class="date">29 July 2019</h4>
<div class="hidden name"><code>EUCAST.Rmd</code></div>

View File

@ -40,7 +40,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -118,13 +118,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -192,7 +185,7 @@
<h1>How to determine multi-drug resistance (MDR)</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">10 July 2019</h4>
<h4 class="date">29 July 2019</h4>
<div class="hidden name"><code>MDR.Rmd</code></div>
@ -235,18 +228,18 @@
<p>The data set looks like this now:</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/utils/topics/head">head</a></span>(my_TB_data)</a>
<a class="sourceLine" id="cb3-2" data-line-number="2"><span class="co"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span></a>
<a class="sourceLine" id="cb3-3" data-line-number="3"><span class="co"># 1 R S S R S R</span></a>
<a class="sourceLine" id="cb3-4" data-line-number="4"><span class="co"># 2 R S R S S S</span></a>
<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="co"># 3 R R R R S R</span></a>
<a class="sourceLine" id="cb3-6" data-line-number="6"><span class="co"># 4 S S R S R S</span></a>
<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="co"># 5 R R S I S S</span></a>
<a class="sourceLine" id="cb3-8" data-line-number="8"><span class="co"># 6 S S R R R S</span></a>
<a class="sourceLine" id="cb3-3" data-line-number="3"><span class="co"># 1 S S S R S S</span></a>
<a class="sourceLine" id="cb3-4" data-line-number="4"><span class="co"># 2 R S R R I R</span></a>
<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="co"># 3 S R R R I R</span></a>
<a class="sourceLine" id="cb3-6" data-line-number="6"><span class="co"># 4 S S R I I R</span></a>
<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="co"># 5 R S R S S R</span></a>
<a class="sourceLine" id="cb3-8" data-line-number="8"><span class="co"># 6 R S R R S R</span></a>
<a class="sourceLine" id="cb3-9" data-line-number="9"><span class="co"># kanamycin</span></a>
<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="co"># 1 S</span></a>
<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="co"># 1 I</span></a>
<a class="sourceLine" id="cb3-11" data-line-number="11"><span class="co"># 2 S</span></a>
<a class="sourceLine" id="cb3-12" data-line-number="12"><span class="co"># 3 S</span></a>
<a class="sourceLine" id="cb3-13" data-line-number="13"><span class="co"># 4 R</span></a>
<a class="sourceLine" id="cb3-14" data-line-number="14"><span class="co"># 5 R</span></a>
<a class="sourceLine" id="cb3-12" data-line-number="12"><span class="co"># 3 R</span></a>
<a class="sourceLine" id="cb3-13" data-line-number="13"><span class="co"># 4 S</span></a>
<a class="sourceLine" id="cb3-14" data-line-number="14"><span class="co"># 5 S</span></a>
<a class="sourceLine" id="cb3-15" data-line-number="15"><span class="co"># 6 S</span></a></code></pre></div>
<p>We can now add the interpretation of MDR-TB to our data set:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1">my_TB_data<span class="op">$</span>mdr &lt;-<span class="st"> </span><span class="kw"><a href="../reference/mdro.html">mdr_tb</a></span>(my_TB_data)</a>
@ -257,9 +250,11 @@
<a class="sourceLine" id="cb4-6" data-line-number="6"><span class="co"># Author: WHO (World Health Organization)</span></a>
<a class="sourceLine" id="cb4-7" data-line-number="7"><span class="co"># Source: https://www.who.int/tb/publications/pmdt_companionhandbook/en/</span></a>
<a class="sourceLine" id="cb4-8" data-line-number="8"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Reliability might be improved if these antimicrobial results would be available too: CAP (capreomycin), RIB (rifabutin), RFP (rifapentine)</span></a></code></pre></div>
<p>And review the result with a frequency table:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="kw"><a href="../reference/freq.html">freq</a></span>(my_TB_data<span class="op">$</span>mdr)</a></code></pre></div>
<p><strong>Frequency table of <code>mdr</code> from <code>my_TB_data</code> (5,000 x 8)</strong></p>
<p>We also created a package dedicated to data cleaning and checking, called the <code>clean</code> package. It gets automatically installed with the <code>AMR</code> package, so we only have to load it:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(clean)</a></code></pre></div>
<p>It contains the <code><a href="https://www.rdocumentation.org/packages/clean/topics/freq">freq()</a></code> function, to create a frequency table:</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="kw"><a href="https://www.rdocumentation.org/packages/clean/topics/freq">freq</a></span>(my_TB_data<span class="op">$</span>mdr)</a></code></pre></div>
<p><strong>Frequency table</strong></p>
<p>Class: factor &gt; ordered (numeric)<br>
Length: 5,000 (of which NA: 0 = 0.00%)<br>
Levels: 5: Negative &lt; Mono-resistance &lt; Poly-resistance &lt; Multidrug resistance…<br>
@ -277,41 +272,41 @@ Unique: 5</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Mono-resistance</td>
<td align="right">3,273</td>
<td align="right">65.5%</td>
<td align="right">3,273</td>
<td align="right">65.5%</td>
<td align="right">3225</td>
<td align="right">64.5%</td>
<td align="right">3225</td>
<td align="right">64.5%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Negative</td>
<td align="right">687</td>
<td align="right">13.7%</td>
<td align="right">3,960</td>
<td align="right">79.2%</td>
<td align="right">644</td>
<td align="right">12.9%</td>
<td align="right">3869</td>
<td align="right">77.4%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Multidrug resistance</td>
<td align="right">569</td>
<td align="right">11.4%</td>
<td align="right">4,529</td>
<td align="right">90.6%</td>
<td align="right">626</td>
<td align="right">12.5%</td>
<td align="right">4495</td>
<td align="right">89.9%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Poly-resistance</td>
<td align="right">277</td>
<td align="right">5.5%</td>
<td align="right">4,806</td>
<td align="right">96.1%</td>
<td align="right">288</td>
<td align="right">5.8%</td>
<td align="right">4783</td>
<td align="right">95.7%</td>
</tr>
<tr class="odd">
<td align="left">5</td>
<td align="left">Extensive drug resistance</td>
<td align="right">194</td>
<td align="right">3.9%</td>
<td align="right">5,000</td>
<td align="right">217</td>
<td align="right">4.3%</td>
<td align="right">5000</td>
<td align="right">100.0%</td>
</tr>
</tbody>

View File

@ -40,7 +40,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -118,13 +118,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -192,7 +185,7 @@
<h1>How to import data from SPSS / SAS / Stata</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">10 July 2019</h4>
<h4 class="date">29 July 2019</h4>
<div class="hidden name"><code>SPSS.Rmd</code></div>

View File

@ -40,7 +40,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -118,13 +118,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -192,7 +185,7 @@
<h1>How to work with WHONET data</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">10 July 2019</h4>
<h4 class="date">29 July 2019</h4>
<div class="hidden name"><code>WHONET.Rmd</code></div>
@ -228,16 +221,20 @@
<a class="sourceLine" id="cb3-4" data-line-number="4"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">mo =</span> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(Organism)) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="st"> </span><span class="co"># transform everything from "AMP_ND10" to "CIP_EE" to the new `rsi` class</span></a>
<a class="sourceLine" id="cb3-6" data-line-number="6"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span>(<span class="kw"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span>(AMP_ND10<span class="op">:</span>CIP_EE), as.rsi)</a></code></pre></div>
<p>No errors or warnings, so all values are transformed succesfully. Lets check it though, with a couple of frequency tables:</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="co"># our newly created `mo` variable</span></a>
<a class="sourceLine" id="cb4-2" data-line-number="2">data <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(mo, <span class="dt">nmax =</span> <span class="dv">10</span>)</a></code></pre></div>
<p><strong>Frequency table of <code>mo</code> from <code>data</code> (500 x 54)</strong></p>
<p>No errors or warnings, so all values are transformed succesfully.</p>
<p>We created a package dedicated to data cleaning and checking, called the <code>clean</code> package. It gets automatically installed with the <code>AMR</code> package, so we only have to load it:</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/library">library</a></span>(clean)</a></code></pre></div>
<p>It contains the <code><a href="https://www.rdocumentation.org/packages/clean/topics/freq">freq()</a></code> function, to create frequency tables.</p>
<p>So lets check our data, with a couple of frequency tables:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="co"># our newly created `mo` variable</span></a>
<a class="sourceLine" id="cb5-2" data-line-number="2">data <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/clean/topics/freq">freq</a></span>(mo, <span class="dt">nmax =</span> <span class="dv">10</span>)</a></code></pre></div>
<p><strong>Frequency table</strong></p>
<p>Class: mo (character)<br>
Length: 500 (of which NA: 0 = 0.00%)<br>
Unique: 39</p>
<p>Families: 10<br>
Genera: 17<br>
Species: 38</p>
Species: 39</p>
<table class="table">
<thead><tr class="header">
<th align="left"></th>
@ -331,18 +328,16 @@ Species: 38</p>
</tbody>
</table>
<p>(omitted 29 entries, n = 57 [11.4%])</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"></a>
<a class="sourceLine" id="cb5-2" data-line-number="2"><span class="co"># our transformed antibiotic columns</span></a>
<a class="sourceLine" id="cb5-3" data-line-number="3"><span class="co"># amoxicillin/clavulanic acid (J01CR02) as an example</span></a>
<a class="sourceLine" id="cb5-4" data-line-number="4">data <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(AMC_ND2)</a></code></pre></div>
<p><strong>Frequency table of <code>AMC_ND2</code> from <code>data</code> (500 x 54)</strong></p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1"></a>
<a class="sourceLine" id="cb6-2" data-line-number="2"><span class="co"># our transformed antibiotic columns</span></a>
<a class="sourceLine" id="cb6-3" data-line-number="3"><span class="co"># amoxicillin/clavulanic acid (J01CR02) as an example</span></a>
<a class="sourceLine" id="cb6-4" data-line-number="4">data <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/clean/topics/freq">freq</a></span>(AMC_ND2)</a></code></pre></div>
<p><strong>Frequency table</strong></p>
<p>Class: factor &gt; ordered &gt; rsi (numeric)<br>
Length: 500 (of which NA: 19 = 3.80%)<br>
Length: 481 (of which NA: 19 = 3.95%)<br>
Levels: 3: S &lt; I &lt; R<br>
Unique: 3</p>
<p>Drug: Amoxicillin/clavulanic acid (AMC, J01CR02)<br>
Group: Beta-lactams/penicillins<br>
%SI: 78.59%</p>
<p>%SI: 78.6%</p>
<table class="table">
<thead><tr class="header">
<th align="left"></th>

View File

@ -40,7 +40,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -118,13 +118,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -192,7 +185,7 @@
<h1>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">10 July 2019</h4>
<h4 class="date">29 July 2019</h4>
<div class="hidden name"><code>benchmarks.Rmd</code></div>
@ -217,14 +210,14 @@
<a class="sourceLine" id="cb2-8" data-line-number="8"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb2-9" data-line-number="9"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb2-10" data-line-number="10"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb2-11" data-line-number="11"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" data-line-number="12"><span class="co"># as.mo("sau") 8.5 8.7 12.0 8.9 9.4 26 10</span></a>
<a class="sourceLine" id="cb2-13" data-line-number="13"><span class="co"># as.mo("stau") 31.0 32.0 42.0 33.0 34.0 120 10</span></a>
<a class="sourceLine" id="cb2-14" data-line-number="14"><span class="co"># as.mo("staaur") 8.6 8.7 11.0 9.1 9.2 26 10</span></a>
<a class="sourceLine" id="cb2-15" data-line-number="15"><span class="co"># as.mo("STAAUR") 8.7 9.1 9.3 9.2 9.4 11 10</span></a>
<a class="sourceLine" id="cb2-16" data-line-number="16"><span class="co"># as.mo("S. aureus") 23.0 23.0 30.0 24.0 40.0 46 10</span></a>
<a class="sourceLine" id="cb2-17" data-line-number="17"><span class="co"># as.mo("S. aureus") 22.0 23.0 27.0 24.0 25.0 41 10</span></a>
<a class="sourceLine" id="cb2-18" data-line-number="18"><span class="co"># as.mo("Staphylococcus aureus") 3.9 4.0 5.7 4.1 4.4 20 10</span></a></code></pre></div>
<a class="sourceLine" id="cb2-11" data-line-number="11"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" data-line-number="12"><span class="co"># as.mo("sau") 8.3 8.4 15.0 8.9 9.5 57.0 10</span></a>
<a class="sourceLine" id="cb2-13" data-line-number="13"><span class="co"># as.mo("stau") 30.0 31.0 42.0 32.0 48.0 110.0 10</span></a>
<a class="sourceLine" id="cb2-14" data-line-number="14"><span class="co"># as.mo("staaur") 8.3 8.4 10.0 8.5 8.9 25.0 10</span></a>
<a class="sourceLine" id="cb2-15" data-line-number="15"><span class="co"># as.mo("STAAUR") 8.1 8.4 10.0 8.4 9.1 24.0 10</span></a>
<a class="sourceLine" id="cb2-16" data-line-number="16"><span class="co"># as.mo("S. aureus") 23.0 23.0 29.0 24.0 38.0 45.0 10</span></a>
<a class="sourceLine" id="cb2-17" data-line-number="17"><span class="co"># as.mo("S. aureus") 22.0 22.0 24.0 23.0 24.0 38.0 10</span></a>
<a class="sourceLine" id="cb2-18" data-line-number="18"><span class="co"># as.mo("Staphylococcus aureus") 3.8 3.9 4.1 4.1 4.2 4.6 10</span></a></code></pre></div>
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.</p>
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Thermus islandicus</em> (<code>B_THERMS_ISL</code>), a bug probably never found before in humans:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1">T.islandicus &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"theisl"</span>),</a>
@ -236,12 +229,12 @@
<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(T.islandicus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb3-8" data-line-number="8"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb3-9" data-line-number="9"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="co"># as.mo("theisl") 290 310 320 320 320 350 10</span></a>
<a class="sourceLine" id="cb3-11" data-line-number="11"><span class="co"># as.mo("THEISL") 290 300 310 310 330 340 10</span></a>
<a class="sourceLine" id="cb3-12" data-line-number="12"><span class="co"># as.mo("T. islandicus") 140 140 150 150 160 170 10</span></a>
<a class="sourceLine" id="cb3-13" data-line-number="13"><span class="co"># as.mo("T. islandicus") 140 140 150 150 170 180 10</span></a>
<a class="sourceLine" id="cb3-14" data-line-number="14"><span class="co"># as.mo("Thermus islandicus") 50 52 58 54 68 70 10</span></a></code></pre></div>
<p>That takes 10.2 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="co"># as.mo("theisl") 250 260 260 260 270 290 10</span></a>
<a class="sourceLine" id="cb3-11" data-line-number="11"><span class="co"># as.mo("THEISL") 250 260 270 260 270 320 10</span></a>
<a class="sourceLine" id="cb3-12" data-line-number="12"><span class="co"># as.mo("T. islandicus") 120 120 130 130 140 150 10</span></a>
<a class="sourceLine" id="cb3-13" data-line-number="13"><span class="co"># as.mo("T. islandicus") 120 130 140 140 140 140 10</span></a>
<a class="sourceLine" id="cb3-14" data-line-number="14"><span class="co"># as.mo("Thermus islandicus") 45 46 55 56 62 67 10</span></a></code></pre></div>
<p>That takes 8.8 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Thermus islandicus</em> (which is very uncommon):</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/graphics/topics/par">par</a></span>(<span class="dt">mar =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">5</span>, <span class="dv">16</span>, <span class="dv">4</span>, <span class="dv">2</span>)) <span class="co"># set more space for left margin text (16)</span></a>
<a class="sourceLine" id="cb4-2" data-line-number="2"></a>
@ -287,8 +280,8 @@
<a class="sourceLine" id="cb5-24" data-line-number="24"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb5-25" data-line-number="25"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb5-26" data-line-number="26"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb5-27" data-line-number="27"><span class="co"># mo_fullname(x) 611 628 643 635 650 714 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.63 seconds (634 ms). You only lose time on your unique input values.</p>
<a class="sourceLine" id="cb5-27" data-line-number="27"><span class="co"># mo_fullname(x) 586 611 623 619 638 671 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.62 seconds (618 ms). You only lose time on your unique input values.</p>
</div>
<div id="precalculated-results" class="section level3">
<h3 class="hasAnchor">
@ -301,10 +294,10 @@
<a class="sourceLine" id="cb6-5" data-line-number="5"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb6-6" data-line-number="6"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb6-7" data-line-number="7"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb6-8" data-line-number="8"><span class="co"># A 6.730 7.030 8.030 7.750 8.72 9.73 10</span></a>
<a class="sourceLine" id="cb6-9" data-line-number="9"><span class="co"># B 22.400 23.000 27.100 23.600 27.10 46.00 10</span></a>
<a class="sourceLine" id="cb6-10" data-line-number="10"><span class="co"># C 0.835 0.877 0.978 0.925 1.12 1.18 10</span></a></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0009 seconds - it doesnt even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
<a class="sourceLine" id="cb6-8" data-line-number="8"><span class="co"># A 6.350 6.600 7.050 6.870 7.35 8.37 10</span></a>
<a class="sourceLine" id="cb6-9" data-line-number="9"><span class="co"># B 21.300 21.500 25.300 22.200 22.70 48.20 10</span></a>
<a class="sourceLine" id="cb6-10" data-line-number="10"><span class="co"># C 0.624 0.753 0.804 0.783 0.87 1.01 10</span></a></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0008 seconds - it doesnt even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">run_it &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</a>
<a class="sourceLine" id="cb7-2" data-line-number="2"> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</a>
<a class="sourceLine" id="cb7-3" data-line-number="3"> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"Staphylococcus aureus"</span>),</a>
@ -317,14 +310,14 @@
<a class="sourceLine" id="cb7-10" data-line-number="10"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb7-11" data-line-number="11"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb7-12" data-line-number="12"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb7-13" data-line-number="13"><span class="co"># A 0.468 0.470 0.533 0.489 0.595 0.690 10</span></a>
<a class="sourceLine" id="cb7-14" data-line-number="14"><span class="co"># B 0.504 0.513 0.555 0.520 0.571 0.711 10</span></a>
<a class="sourceLine" id="cb7-15" data-line-number="15"><span class="co"># C 0.629 0.687 0.864 0.855 1.050 1.130 10</span></a>
<a class="sourceLine" id="cb7-16" data-line-number="16"><span class="co"># D 0.505 0.515 0.575 0.530 0.649 0.767 10</span></a>
<a class="sourceLine" id="cb7-17" data-line-number="17"><span class="co"># E 0.442 0.457 0.529 0.481 0.531 0.774 10</span></a>
<a class="sourceLine" id="cb7-18" data-line-number="18"><span class="co"># F 0.447 0.510 0.554 0.568 0.609 0.618 10</span></a>
<a class="sourceLine" id="cb7-19" data-line-number="19"><span class="co"># G 0.443 0.470 0.492 0.477 0.506 0.601 10</span></a>
<a class="sourceLine" id="cb7-20" data-line-number="20"><span class="co"># H 0.448 0.459 0.491 0.466 0.515 0.633 10</span></a></code></pre></div>
<a class="sourceLine" id="cb7-13" data-line-number="13"><span class="co"># A 0.436 0.454 0.460 0.460 0.462 0.491 10</span></a>
<a class="sourceLine" id="cb7-14" data-line-number="14"><span class="co"># B 0.472 0.480 0.496 0.488 0.513 0.542 10</span></a>
<a class="sourceLine" id="cb7-15" data-line-number="15"><span class="co"># C 0.657 0.672 0.757 0.750 0.797 0.952 10</span></a>
<a class="sourceLine" id="cb7-16" data-line-number="16"><span class="co"># D 0.478 0.495 0.500 0.499 0.503 0.540 10</span></a>
<a class="sourceLine" id="cb7-17" data-line-number="17"><span class="co"># E 0.436 0.446 0.456 0.448 0.455 0.507 10</span></a>
<a class="sourceLine" id="cb7-18" data-line-number="18"><span class="co"># F 0.437 0.447 0.455 0.454 0.460 0.478 10</span></a>
<a class="sourceLine" id="cb7-19" data-line-number="19"><span class="co"># G 0.428 0.441 0.449 0.447 0.455 0.477 10</span></a>
<a class="sourceLine" id="cb7-20" data-line-number="20"><span class="co"># H 0.438 0.445 0.456 0.451 0.472 0.477 10</span></a></code></pre></div>
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> too, there is no point in calculating the result. And because this package knows all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.</p>
</div>
<div id="results-in-other-languages" class="section level3">
@ -351,13 +344,13 @@
<a class="sourceLine" id="cb8-18" data-line-number="18"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</a>
<a class="sourceLine" id="cb8-19" data-line-number="19"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb8-20" data-line-number="20"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb8-21" data-line-number="21"><span class="co"># en 19.29 20.39 22.42 20.64 21.26 38.98 10</span></a>
<a class="sourceLine" id="cb8-22" data-line-number="22"><span class="co"># de 22.03 22.40 23.78 23.08 23.60 31.74 10</span></a>
<a class="sourceLine" id="cb8-23" data-line-number="23"><span class="co"># nl 27.98 28.60 29.22 28.87 30.13 30.53 10</span></a>
<a class="sourceLine" id="cb8-24" data-line-number="24"><span class="co"># es 21.44 22.97 30.04 24.11 45.71 46.46 10</span></a>
<a class="sourceLine" id="cb8-25" data-line-number="25"><span class="co"># it 21.17 21.82 22.47 22.44 23.27 23.52 10</span></a>
<a class="sourceLine" id="cb8-26" data-line-number="26"><span class="co"># fr 20.75 21.58 24.10 22.04 22.41 42.96 10</span></a>
<a class="sourceLine" id="cb8-27" data-line-number="27"><span class="co"># pt 21.24 21.92 24.31 22.75 23.26 39.91 10</span></a></code></pre></div>
<a class="sourceLine" id="cb8-21" data-line-number="21"><span class="co"># en 17.21 17.67 18.20 18.40 18.62 18.81 10</span></a>
<a class="sourceLine" id="cb8-22" data-line-number="22"><span class="co"># de 18.76 19.01 21.59 19.45 19.82 41.96 10</span></a>
<a class="sourceLine" id="cb8-23" data-line-number="23"><span class="co"># nl 24.15 24.57 29.11 25.67 26.49 45.25 10</span></a>
<a class="sourceLine" id="cb8-24" data-line-number="24"><span class="co"># es 18.31 19.02 19.33 19.37 19.93 20.09 10</span></a>
<a class="sourceLine" id="cb8-25" data-line-number="25"><span class="co"># it 18.96 19.27 23.48 19.58 20.91 41.27 10</span></a>
<a class="sourceLine" id="cb8-26" data-line-number="26"><span class="co"># fr 18.33 18.80 19.46 19.27 19.97 21.10 10</span></a>
<a class="sourceLine" id="cb8-27" data-line-number="27"><span class="co"># pt 18.89 19.50 20.54 19.70 20.36 27.83 10</span></a></code></pre></div>
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
</div>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -78,7 +78,7 @@
</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="Latest development version">0.7.1.9014</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -156,13 +156,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -242,7 +235,6 @@
<li><a href="SPSS.html">How to import data from SPSS / SAS / Stata</a></li>
<li><a href="WHONET.html">How to work with WHONET data</a></li>
<li><a href="benchmarks.html">Benchmarks</a></li>
<li><a href="freq.html">How to create frequency tables</a></li>
<li><a href="resistance_predict.html">How to predict antimicrobial resistance</a></li>
</ul>
</div>

View File

@ -40,7 +40,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -118,13 +118,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -192,7 +185,7 @@
<h1>How to predict antimicrobial resistance</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">10 July 2019</h4>
<h4 class="date">29 July 2019</h4>
<div class="hidden name"><code>resistance_predict.Rmd</code></div>

View File

@ -78,7 +78,7 @@
</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="Latest development version">0.7.1.9014</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -156,13 +156,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -42,7 +42,7 @@
</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="Latest development version">0.7.1.9014</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -120,13 +120,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -213,7 +206,6 @@
<li>Plotting antimicrobial resistance (<a href="./articles/AMR.html">tutorial</a>)</li>
<li>Determining first isolates to be used for AMR analysis (<a href="./reference/first_isolate.html">manual</a>)</li>
<li>Applying EUCAST expert rules (<a href="./reference/eucast_rules.html">manual</a>)</li>
<li>Descriptive statistics: frequency tables, kurtosis and skewness (<a href="./articles/freq.html">tutorial</a>)</li>
</ul>
<p>This package is ready-to-use for a professional environment by specialists in the following fields:</p>
<p>Medical Microbiology</p>
@ -340,8 +332,6 @@
<li>Calculate the resistance (and even co-resistance) of microbial isolates with the <code><a href="reference/portion.html">portion_R()</a></code>, <code><a href="reference/portion.html">portion_IR()</a></code>, <code><a href="reference/portion.html">portion_I()</a></code>, <code><a href="reference/portion.html">portion_SI()</a></code> and <code><a href="reference/portion.html">portion_S()</a></code> functions. Similarly, the <em>number</em> of isolates can be determined with the <code><a href="reference/count.html">count_R()</a></code>, <code><a href="reference/count.html">count_IR()</a></code>, <code><a href="reference/count.html">count_I()</a></code>, <code><a href="reference/count.html">count_SI()</a></code> and <code><a href="reference/count.html">count_S()</a></code> functions. All these functions can be used with the <code>dplyr</code> package (e.g. in conjunction with <code>summarise()</code>)</li>
<li>Plot AMR results with <code><a href="reference/ggplot_rsi.html">geom_rsi()</a></code>, a function made for the <code>ggplot2</code> package</li>
<li>Predict antimicrobial resistance for the nextcoming years using logistic regression models with the <code><a href="reference/resistance_predict.html">resistance_predict()</a></code> function</li>
<li>Conduct descriptive statistics to enhance base R: calculate <code><a href="reference/kurtosis.html">kurtosis()</a></code>, <code><a href="reference/skewness.html">skewness()</a></code> and create frequency tables with <code><a href="reference/freq.html">freq()</a></code>
</li>
</ul>
</li>
<li>

View File

@ -78,7 +78,7 @@
</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="Latest development version">0.7.1.9014</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -156,13 +156,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -232,10 +225,17 @@
</div>
<div id="amr-0-7-1-9014" class="section level1">
<div id="amr-0-7-1-9015" class="section level1">
<h1 class="page-header">
<a href="#amr-0-7-1-9014" class="anchor"></a>AMR 0.7.1.9014<small> Unreleased </small>
<a href="#amr-0-7-1-9015" class="anchor"></a>AMR 0.7.1.9015<small> Unreleased </small>
</h1>
<div id="breaking" class="section level3">
<h3 class="hasAnchor">
<a href="#breaking" class="anchor"></a>Breaking</h3>
<ul>
<li>Function <code>freq()</code> has moved to a new package, <a href="https://github.com/msberends/clean"><code>clean</code></a> (<a href="https://cran.r-project.org/package=clean">CRAN link</a>). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. We decided to create a new package for data cleaning and checking and it perfectly fits the <code>freq()</code> function. The <a href="https://github.com/msberends/clean"><code>clean</code></a> package is available on CRAN and will be installed automatically when updating the <code>AMR</code> package, that now imports it. In a later stage, the <code><a href="../reference/skewness.html">skewness()</a></code> and <code><a href="../reference/kurtosis.html">kurtosis()</a></code> functions will be moved to the <code>clean</code> package too.</li>
</ul>
</div>
<div id="new" class="section level3">
<h3 class="hasAnchor">
<a href="#new" class="anchor"></a>New</h3>
@ -421,7 +421,7 @@ Please <a href="https://gitlab.com/msberends/AMR/issues/new?issue%5Btitle%5D=Tra
<li>The <code><a href="../reference/age.html">age()</a></code> function gained a new parameter <code>exact</code> to determine ages with decimals</li>
<li>Removed deprecated functions <code>guess_mo()</code>, <code>guess_atc()</code>, <code>EUCAST_rules()</code>, <code>interpretive_reading()</code>, <code>rsi()</code>
</li>
<li>Frequency tables (<code><a href="../reference/freq.html">freq()</a></code>):
<li>Frequency tables (<code>freq()</code>):
<ul>
<li>speed improvement for microbial IDs</li>
<li>fixed factor level names for R Markdown</li>
@ -429,12 +429,12 @@ Please <a href="https://gitlab.com/msberends/AMR/issues/new?issue%5Btitle%5D=Tra
<li>
<p>support for boxplots:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(age) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-2" data-line-number="2"><span class="st"> </span><span class="kw">freq</span>(age) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/boxplot">boxplot</a></span>()</a>
<a class="sourceLine" id="cb4-4" data-line-number="4"><span class="co"># grouped boxplots:</span></a>
<a class="sourceLine" id="cb4-5" data-line-number="5">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-6" data-line-number="6"><span class="st"> </span><span class="kw">group_by</span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-7" data-line-number="7"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(age) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb4-7" data-line-number="7"><span class="st"> </span><span class="kw">freq</span>(age) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb4-8" data-line-number="8"><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/boxplot">boxplot</a></span>()</a></code></pre></div>
</li>
</ul>
@ -445,7 +445,7 @@ Please <a href="https://gitlab.com/msberends/AMR/issues/new?issue%5Btitle%5D=EUC
<li>Added ceftazidim intrinsic resistance to <em>Streptococci</em>
</li>
<li>Changed default settings for <code><a href="../reference/age_groups.html">age_groups()</a></code>, to let groups of fives and tens end with 100+ instead of 120+</li>
<li>Fix for <code><a href="../reference/freq.html">freq()</a></code> for when all values are <code>NA</code>
<li>Fix for <code>freq()</code> for when all values are <code>NA</code>
</li>
<li>Fix for <code><a href="../reference/first_isolate.html">first_isolate()</a></code> for when dates are missing</li>
<li>Improved speed of <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code>
@ -667,7 +667,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
</li>
</ul>
</li>
<li>Frequency tables (<code><a href="../reference/freq.html">freq()</a></code> function):
<li>Frequency tables (<code>freq()</code> function):
<ul>
<li>
<p>Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:</p>
@ -675,15 +675,15 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<a class="sourceLine" id="cb14-2" data-line-number="2"><span class="co"># OLD WAY</span></a>
<a class="sourceLine" id="cb14-3" data-line-number="3">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb14-4" data-line-number="4"><span class="st"> </span><span class="kw">mutate</span>(<span class="dt">genus =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo)) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb14-5" data-line-number="5"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(genus)</a>
<a class="sourceLine" id="cb14-5" data-line-number="5"><span class="st"> </span><span class="kw">freq</span>(genus)</a>
<a class="sourceLine" id="cb14-6" data-line-number="6"><span class="co"># NEW WAY</span></a>
<a class="sourceLine" id="cb14-7" data-line-number="7">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb14-8" data-line-number="8"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a>
<a class="sourceLine" id="cb14-8" data-line-number="8"><span class="st"> </span><span class="kw">freq</span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a>
<a class="sourceLine" id="cb14-9" data-line-number="9"></a>
<a class="sourceLine" id="cb14-10" data-line-number="10"><span class="co"># Even supports grouping variables:</span></a>
<a class="sourceLine" id="cb14-11" data-line-number="11">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb14-12" data-line-number="12"><span class="st"> </span><span class="kw">group_by</span>(gender) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb14-13" data-line-number="13"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a></code></pre></div>
<a class="sourceLine" id="cb14-13" data-line-number="13"><span class="st"> </span><span class="kw">freq</span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a></code></pre></div>
</li>
<li>Header info is now available as a list, with the <code>header</code> function</li>
<li>The parameter <code>header</code> is now set to <code>TRUE</code> at default, even for markdown</li>
@ -770,18 +770,18 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<li>Using <code>portion_*</code> functions now throws a warning when total available isolate is below parameter <code>minimum</code>
</li>
<li>Functions <code>as.mo</code>, <code>as.rsi</code>, <code>as.mic</code>, <code>as.atc</code> and <code>freq</code> will not set package name as attribute anymore</li>
<li>Frequency tables - <code><a href="../reference/freq.html">freq()</a></code>:
<li>Frequency tables - <code>freq()</code>:
<ul>
<li>
<p>Support for grouping variables, test with:</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb16-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb16-2" data-line-number="2"><span class="st"> </span><span class="kw">group_by</span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb16-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</a></code></pre></div>
<a class="sourceLine" id="cb16-3" data-line-number="3"><span class="st"> </span><span class="kw">freq</span>(gender)</a></code></pre></div>
</li>
<li>
<p>Support for (un)selecting columns:</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb17-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb17-2" data-line-number="2"><span class="st"> </span><span class="kw">freq</span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb17-3" data-line-number="3"><span class="st"> </span><span class="kw">select</span>(<span class="op">-</span>count, <span class="op">-</span>cum_count) <span class="co"># only get item, percent, cum_percent</span></a></code></pre></div>
</li>
<li>Check for <code><a href="https://www.rdocumentation.org/packages/hms/topics/Deprecated">hms::is.hms</a></code>
@ -802,7 +802,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<li>Removed diacritics from all authors (columns <code>microorganisms$ref</code> and <code>microorganisms.old$ref</code>) to comply with CRAN policy to only allow ASCII characters</li>
<li>Fix for <code>mo_property</code> not working properly</li>
<li>Fix for <code>eucast_rules</code> where some Streptococci would become ceftazidime R in EUCAST rule 4.5</li>
<li>Support for named vectors of class <code>mo</code>, useful for <code><a href="../reference/freq.html">top_freq()</a></code>
<li>Support for named vectors of class <code>mo</code>, useful for <code>top_freq()</code>
</li>
<li>
<code>ggplot_rsi</code> and <code>scale_y_percent</code> have <code>breaks</code> parameter</li>
@ -960,11 +960,11 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<li>
<p>Support for types (classes) list and matrix for <code>freq</code></p>
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb24-1" data-line-number="1">my_matrix =<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/with">with</a></span>(septic_patients, <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/matrix">matrix</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(age, gender), <span class="dt">ncol =</span> <span class="dv">2</span>))</a>
<a class="sourceLine" id="cb24-2" data-line-number="2"><span class="kw"><a href="../reference/freq.html">freq</a></span>(my_matrix)</a></code></pre></div>
<a class="sourceLine" id="cb24-2" data-line-number="2"><span class="kw">freq</span>(my_matrix)</a></code></pre></div>
<p>For lists, subsetting is possible:</p>
<div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb25-1" data-line-number="1">my_list =<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">age =</span> septic_patients<span class="op">$</span>age, <span class="dt">gender =</span> septic_patients<span class="op">$</span>gender)</a>
<a class="sourceLine" id="cb25-2" data-line-number="2">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(age)</a>
<a class="sourceLine" id="cb25-3" data-line-number="3">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</a></code></pre></div>
<a class="sourceLine" id="cb25-2" data-line-number="2">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">freq</span>(age)</a>
<a class="sourceLine" id="cb25-3" data-line-number="3">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">freq</span>(gender)</a></code></pre></div>
</li>
</ul>
</div>
@ -1038,13 +1038,13 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<ul>
<li>A vignette to explain its usage</li>
<li>Support for <code>rsi</code> (antimicrobial resistance) to use as input</li>
<li>Support for <code>table</code> to use as input: <code><a href="../reference/freq.html">freq(table(x, y))</a></code>
<li>Support for <code>table</code> to use as input: <code>freq(table(x, y))</code>
</li>
<li>Support for existing functions <code>hist</code> and <code>plot</code> to use a frequency table as input: <code><a href="https://www.rdocumentation.org/packages/graphics/topics/hist">hist(freq(df$age))</a></code>
</li>
<li>Support for <code>as.vector</code>, <code>as.data.frame</code>, <code>as_tibble</code> and <code>format</code>
</li>
<li>Support for quasiquotation: <code><a href="../reference/freq.html">freq(mydata, mycolumn)</a></code> is the same as <code>mydata %&gt;% freq(mycolumn)</code>
<li>Support for quasiquotation: <code>freq(mydata, mycolumn)</code> is the same as <code>mydata %&gt;% freq(mycolumn)</code>
</li>
<li>Function <code>top_freq</code> function to return the top/below <em>n</em> items as vector</li>
<li>Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)</li>
@ -1198,7 +1198,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<div id="tocnav">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#amr-0-7-1-9014">0.7.1.9014</a></li>
<li><a href="#amr-0-7-1-9015">0.7.1.9015</a></li>
<li><a href="#amr-0-7-1">0.7.1</a></li>
<li><a href="#amr-0-7-0">0.7.0</a></li>
<li><a href="#amr-0-6-1">0.6.1</a></li>

View File

@ -8,7 +8,6 @@ articles:
SPSS: SPSS.html
WHONET: WHONET.html
benchmarks: benchmarks.html
freq: freq.html
resistance_predict: resistance_predict.html
urls:
reference: https://msberends.gitlab.io/AMR/reference

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -296,7 +289,7 @@
<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/barplot'>barplot</a></span>(<span class='no'>mic_data</span>)
<span class='fu'><a href='freq.html'>freq</a></span>(<span class='no'>mic_data</span>)
<span class='fu'>freq</span>(<span class='no'>mic_data</span>)
<span class='co'># }</span></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -343,7 +336,7 @@
<span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/plot'>plot</a></span>(<span class='no'>rsi_data</span>) <span class='co'># for percentages</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/barplot'>barplot</a></span>(<span class='no'>rsi_data</span>) <span class='co'># for frequencies</span>
<span class='fu'><a href='freq.html'>freq</a></span>(<span class='no'>rsi_data</span>) <span class='co'># frequency table with informative header</span>
<span class='fu'>freq</span>(<span class='no'>rsi_data</span>) <span class='co'># frequency table with informative header</span>
<span class='co'># using dplyr's mutate</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -271,8 +264,8 @@ This package contains the complete taxonomic tree of almost all microorganisms (
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</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'>microorganisms</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='freq.html'>freq</a></span>(<span class='no'>kingdom</span>)
<span class='no'>microorganisms</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>kingdom</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='freq.html'>freq</a></span>(<span class='no'>phylum</span>, <span class='kw'>nmax</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)
<span class='no'>microorganisms</span> <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>kingdom</span>)
<span class='no'>microorganisms</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>kingdom</span>) <span class='kw'>%&gt;%</span> <span class='fu'>freq</span>(<span class='no'>phylum</span>, <span class='kw'>nmax</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)
<span class='co'># }</span></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@ -81,7 +81,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -159,13 +159,6 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -457,7 +450,7 @@
<span class='co'># create new bacterial ID's, with all CoNS under the same group (Becker et al.)</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>mo</span> <span class='kw'>=</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='no'>mo</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)) <span class='kw'>%&gt;%</span>
<span class='co'># filter on top three bacterial ID's</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>mo</span> <span class='kw'>%in%</span> <span class='fu'><a href='freq.html'>top_freq</a></span>(<span class='fu'><a href='freq.html'>freq</a></span>(<span class='no'>.</span>$<span class='no'>mo</span>), <span class='fl'>3</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>mo</span> <span class='kw'>%in%</span> <span class='fu'>top_freq</span>(<span class='fu'>freq</span>(<span class='no'>.</span>$<span class='no'>mo</span>), <span class='fl'>3</span>)) <span class='kw'>%&gt;%</span>
<span class='co'># filter on first isolates</span>
<span class='fu'><a href='first_isolate.html'>filter_first_isolate</a></span>() <span class='kw'>%&gt;%</span>
<span class='co'># get short MO names (like "E. coli")</span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -78,7 +78,7 @@
</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="Latest development version">0.7.1.9014</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -156,13 +156,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -411,7 +404,7 @@
<tr>
<th colspan="2">
<h2 id="section-analysing-your-data" class="hasAnchor"><a href="#section-analysing-your-data" class="anchor"></a>Analysing your data</h2>
<p class="section-desc"><p>Functions for conducting AMR analysis, like counting isolates, calculating resistance or susceptibility, creating frequency tables or make plots.</p></p>
<p class="section-desc"><p>Functions for conducting AMR analysis, like counting isolates, calculating resistance or susceptibility, or make plots.</p></p>
</th>
</tr>
<tr>
@ -440,12 +433,6 @@
<td><p>Filter isolates on result in antibiotic class</p></td>
</tr><tr>
<td>
<p><code><a href="freq.html">freq()</a></code> <code><a href="freq.html">frequency_tbl()</a></code> <code><a href="freq.html">top_freq()</a></code> <code><a href="freq.html">header()</a></code> <code><a href="freq.html">print(<i>&lt;freq&gt;</i>)</a></code> </p>
</td>
<td><p>Frequency table</p></td>
</tr><tr>
<td>
<p><code><a href="g.test.html">g.test()</a></code> </p>
</td>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
@ -309,7 +302,7 @@
<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='https://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'>freq</span>(<span class='no'>genus</span>, <span class='no'>species</span>)
<span class='co'># }</span></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -81,7 +81,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -159,13 +159,6 @@ This is the fastest way to have your organisation (or analysis) specific codes p
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -81,7 +81,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -159,13 +159,6 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -81,7 +81,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -159,13 +159,6 @@ When negative: the left tail is longer; the mass of the distribution is concentr
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -80,7 +80,7 @@
</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="Latest development version">0.7.1.9012</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9015</span>
</span>
</div>
@ -158,13 +158,6 @@
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>

View File

@ -69,9 +69,6 @@
<url>
<loc>https://msberends.gitlab.io/AMR/reference/first_isolate.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/freq.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/g.test.html</loc>
</url>
@ -153,9 +150,6 @@
<url>
<loc>https://msberends.gitlab.io/AMR/articles/benchmarks.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/articles/freq.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/articles/resistance_predict.html</loc>
</url>

View File

@ -26,7 +26,6 @@ This package can be used for:
* Plotting antimicrobial resistance ([tutorial](./articles/AMR.html))
* Determining first isolates to be used for AMR analysis ([manual](./reference/first_isolate.html))
* Applying EUCAST expert rules ([manual](./reference/eucast_rules.html))
* Descriptive statistics: frequency tables, kurtosis and skewness ([tutorial](./articles/freq.html))
This package is ready-to-use for a professional environment by specialists in the following fields:
@ -154,7 +153,6 @@ The `AMR` package basically does four important things:
* Calculate the resistance (and even co-resistance) of microbial isolates with the `portion_R()`, `portion_IR()`, `portion_I()`, `portion_SI()` and `portion_S()` functions. Similarly, the *number* of isolates can be determined with the `count_R()`, `count_IR()`, `count_I()`, `count_SI()` and `count_S()` functions. All these functions can be used with the `dplyr` package (e.g. in conjunction with `summarise()`)
* Plot AMR results with `geom_rsi()`, a function made for the `ggplot2` package
* Predict antimicrobial resistance for the nextcoming years using logistic regression models with the `resistance_predict()` function
* Conduct descriptive statistics to enhance base R: calculate `kurtosis()`, `skewness()` and create frequency tables with `freq()`
4. It **teaches the user** how to use all the above actions.

View File

@ -1,234 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/freq.R
\name{freq}
\alias{freq}
\alias{frequency_tbl}
\alias{top_freq}
\alias{header}
\alias{print.freq}
\title{Frequency table}
\usage{
freq(x, ..., sort.count = TRUE, nmax = getOption("max.print.freq"),
na.rm = TRUE, row.names = TRUE, markdown = !interactive(),
digits = 2, quote = NULL, header = TRUE, title = NULL,
na = "<NA>", droplevels = TRUE, sep = " ",
decimal.mark = getOption("OutDec"), big.mark = ifelse(decimal.mark !=
",", ",", "."))
frequency_tbl(x, ..., sort.count = TRUE,
nmax = getOption("max.print.freq"), na.rm = TRUE, row.names = TRUE,
markdown = !interactive(), digits = 2, quote = NULL,
header = TRUE, title = NULL, na = "<NA>", droplevels = TRUE,
sep = " ", decimal.mark = getOption("OutDec"),
big.mark = ifelse(decimal.mark != ",", ",", "."))
top_freq(f, n)
header(f, property = NULL)
\method{print}{freq}(x, nmax = getOption("max.print.freq", default = 15),
markdown = !interactive(), header = TRUE,
decimal.mark = getOption("OutDec"), big.mark = ifelse(decimal.mark !=
",", ",", "."), ...)
}
\arguments{
\item{x}{vector of any class or a \code{\link{data.frame}}, \code{\link{tibble}} (may contain a grouping variable) or \code{\link{table}}}
\item{...}{up to nine different columns of \code{x} when \code{x} is a \code{data.frame} or \code{tibble}, to calculate frequencies from - see Examples. Also supports quasiquotion.}
\item{sort.count}{sort on count, i.e. frequencies. This will be \code{TRUE} at default for everything except when using grouping variables.}
\item{nmax}{number of row to print. The default, \code{15}, uses \code{\link{getOption}("max.print.freq")}. Use \code{nmax = 0}, \code{nmax = Inf}, \code{nmax = NULL} or \code{nmax = NA} to print all rows.}
\item{na.rm}{a logical value indicating whether \code{NA} values should be removed from the frequency table. The header (if set) will always print the amount of \code{NA}s.}
\item{row.names}{a logical value indicating whether row indices should be printed as \code{1:nrow(x)}}
\item{markdown}{a logical value indicating whether the frequency table should be printed in markdown format. This will print all rows (except when \code{nmax} is defined) and is default behaviour in non-interactive R sessions (like when knitting RMarkdown files).}
\item{digits}{how many significant digits are to be used for numeric values in the header (not for the items themselves, that depends on \code{\link{getOption}("digits")})}
\item{quote}{a logical value indicating whether or not strings should be printed with surrounding quotes. Default is to print them only around characters that are actually numeric values.}
\item{header}{a logical value indicating whether an informative header should be printed}
\item{title}{text to show above frequency table, at default to tries to coerce from the variables passed to \code{x}}
\item{na}{a character string that should be used to show empty (\code{NA}) values (only useful when \code{na.rm = FALSE})}
\item{droplevels}{a logical value indicating whether in factors empty levels should be dropped}
\item{sep}{a character string to separate the terms when selecting multiple columns}
\item{decimal.mark}{%
used for prettying (longish) numerical and complex sequences.
Passed to \code{\link{prettyNum}}: that help page explains the details.}
\item{big.mark}{%
used for prettying (longish) numerical and complex sequences.
Passed to \code{\link{prettyNum}}: that help page explains the details.}
\item{f}{a frequency table}
\item{n}{number of top \emph{n} items to return, use -n for the bottom \emph{n} items. It will include more than \code{n} rows if there are ties.}
\item{property}{property in header to return this value directly}
}
\value{
A \code{data.frame} (with an additional class \code{"freq"}) with five columns: \code{item}, \code{count}, \code{percent}, \code{cum_count} and \code{cum_percent}.
}
\description{
Create a frequency table of a vector with items or a \code{data.frame}. Supports quasiquotation and markdown for reports. Best practice is: \code{data \%>\% freq(var)}.\cr
\code{top_freq} can be used to get the top/bottom \emph{n} items of a frequency table, with counts as names.
}
\details{
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{browseVignettes("AMR")} to read it.
For numeric values of any class, these additional values will all be calculated with \code{na.rm = TRUE} and shown into the header:
\itemize{
\item{Mean, using \code{\link[base]{mean}}}
\item{Standard Deviation, using \code{\link[stats]{sd}}}
\item{Coefficient of Variation (CV), the standard deviation divided by the mean}
\item{Mean Absolute Deviation (MAD), using \code{\link[stats]{mad}}}
\item{Tukey Five-Number Summaries (minimum, Q1, median, Q3, maximum), using \code{\link[stats]{fivenum}}}
\item{Interquartile Range (IQR) calculated as \code{Q3 - Q1} using the Tukey Five-Number Summaries, i.e. \strong{not} using the \code{\link[stats]{quantile}} function}
\item{Coefficient of Quartile Variation (CQV, sometimes called coefficient of dispersion), calculated as \code{(Q3 - Q1) / (Q3 + Q1)} using the Tukey Five-Number Summaries}
\item{Outliers (total count and unique count), using \code{\link[grDevices]{boxplot.stats}}}
}
For dates and times of any class, these additional values will be calculated with \code{na.rm = TRUE} and shown into the header:
\itemize{
\item{Oldest, using \code{\link{min}}}
\item{Newest, using \code{\link{max}}, with difference between newest and oldest}
\item{Median, using \code{\link[stats]{median}}, with percentage since oldest}
}
In factors, all factor levels that are not existing in the input data will be dropped.
The function \code{top_freq} uses \code{\link[dplyr]{top_n}} internally and will include more than \code{n} rows if there are ties.
}
\section{Read more on our website!}{
On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}.
}
\examples{
library(dplyr)
# this all gives the same result:
freq(septic_patients$hospital_id)
freq(septic_patients[, "hospital_id"])
septic_patients$hospital_id \%>\% freq()
septic_patients[, "hospital_id"] \%>\% freq()
septic_patients \%>\% freq("hospital_id")
septic_patients \%>\% freq(hospital_id) #<- easiest to remember (tidyverse)
# you could also use `select` or `pull` to get your variables
septic_patients \%>\%
filter(hospital_id == "A") \%>\%
select(mo) \%>\%
freq()
# multiple selected variables will be pasted together
septic_patients \%>\%
left_join_microorganisms \%>\%
freq(genus, species)
# functions as quasiquotation are also supported
septic_patients \%>\%
freq(mo_genus(mo), mo_species(mo))
# group a variable and analyse another
septic_patients \%>\%
group_by(hospital_id) \%>\%
freq(gender)
# get top 10 bugs of hospital A as a vector
septic_patients \%>\%
filter(hospital_id == "A") \%>\%
freq(mo) \%>\%
top_freq(10)
# save frequency table to an object
years <- septic_patients \%>\%
mutate(year = format(date, "\%Y")) \%>\%
freq(year)
# show only the top 5
years \%>\% print(nmax = 5)
# save to an object with formatted percentages
years <- format(years)
# print a histogram of numeric values
septic_patients \%>\%
freq(age) \%>\%
hist()
# or a boxplot of numeric values
septic_patients \%>\%
freq(age) \%>\%
boxplot()
# or even a boxplot per group
septic_patients \%>\%
group_by(hospital_id) \%>\%
freq(age) \%>\%
boxplot()
# or print all points to a regular plot
septic_patients \%>\%
freq(age) \%>\%
plot()
# transform to a data.frame or tibble
septic_patients \%>\%
freq(age) \%>\%
as.data.frame()
# or transform (back) to a vector
septic_patients \%>\%
freq(age) \%>\%
as.vector()
identical(septic_patients \%>\%
freq(age) \%>\%
as.vector() \%>\%
sort(),
sort(septic_patients$age)) # TRUE
# it also supports `table` objects
table(septic_patients$gender,
septic_patients$age) \%>\%
freq(sep = " **sep** ")
# only get selected columns
septic_patients \%>\%
freq(hospital_id) \%>\%
select(item, percent)
septic_patients \%>\%
freq(hospital_id) \%>\%
select(-count, -cum_count)
# check differences between frequency tables
diff(freq(septic_patients$TMP),
freq(septic_patients$SXT))
}
\keyword{freq}
\keyword{frequency}
\keyword{summarise}
\keyword{summary}

View File

@ -22,168 +22,10 @@
context("freq.R")
test_that("frequency table works", {
library(dplyr)
expect_equal(nrow(freq(c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5))), 5)
expect_equal(nrow(frequency_tbl(c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5))), 5)
# date column of septic_patients should contain 1140 unique dates
expect_equal(nrow(freq(septic_patients$date)), 1140)
expect_equal(nrow(freq(septic_patients$date)),
length(unique(septic_patients$date)))
expect_output(print(septic_patients %>% freq(age)))
expect_output(print(septic_patients %>% freq(age, nmax = 5)))
expect_output(print(septic_patients %>% freq(age, nmax = Inf, markdown = FALSE)))
expect_output(print(freq(septic_patients$age, nmax = Inf)))
expect_output(print(freq(septic_patients$age, nmax = NA)))
expect_output(print(freq(septic_patients$age, nmax = NULL)))
expect_output(print(freq(septic_patients$age, sort.count = FALSE)))
expect_output(print(freq(septic_patients$age, markdown = TRUE)))
expect_output(print(freq(septic_patients$age, markdown = TRUE), markdown = FALSE))
expect_output(print(freq(septic_patients$age, markdown = TRUE), markdown = TRUE))
expect_output(print(freq(septic_patients$age[0])))
expect_output(print(freq(septic_patients$age, quote = TRUE)))
expect_output(print(freq(septic_patients$age, markdown = TRUE, title = "TITLE")))
# character
expect_output(print(freq(microorganisms$genus)))
expect_output(print(structure(freq(microorganisms$genus),
# check printing of old class:
class = c("frequency_tbl", "data.frame"))))
library(clean)
# mo
expect_output(print(freq(septic_patients$mo)))
# rsi
expect_output(print(freq(septic_patients$AMX)))
# integer
expect_output(print(freq(septic_patients$age)))
# date
expect_output(print(freq(septic_patients$date)))
# factor
expect_output(print(freq(septic_patients$hospital_id)))
# table
expect_output(print(freq(table(septic_patients$gender, septic_patients$age))))
# rsi
expect_output(print(freq(septic_patients$AMC)))
# hms
expect_output(print(freq(hms::as.hms(sample(c(0:86399), 50)))))
# matrix
expect_output(print(freq(as.matrix(septic_patients$age))))
expect_output(print(freq(as.matrix(septic_patients[, c("age", "gender")]))))
# list
expect_output(print(freq(list(age = septic_patients$age))))
expect_output(print(freq(list(age = septic_patients$age, gender = septic_patients$gender))))
# difftime
expect_output(print(
freq(difftime(Sys.time(),
Sys.time() - runif(5, min = 0, max = 60 * 60 * 24),
units = "hours"))))
expect_output(print(freq(septic_patients$age)[,1:3]))
library(dplyr)
expect_output(septic_patients %>% select(1:2) %>% freq() %>% print())
expect_output(septic_patients %>% select(1:3) %>% freq() %>% print())
expect_output(septic_patients %>% select(1:4) %>% freq() %>% print())
expect_output(septic_patients %>% select(1:5) %>% freq() %>% print())
expect_output(septic_patients %>% select(1:6) %>% freq() %>% print())
expect_output(septic_patients %>% select(1:7) %>% freq() %>% print())
expect_output(septic_patients %>% select(1:8) %>% freq() %>% print())
expect_output(septic_patients %>% select(1:9) %>% freq() %>% print())
expect_output(print(freq(septic_patients$age), nmax = 20))
# grouping variable
expect_output(print(septic_patients %>% group_by(gender) %>% freq(hospital_id)))
expect_output(print(septic_patients %>% group_by(gender) %>% freq(AMX, quote = TRUE)))
expect_output(print(septic_patients %>% group_by(gender) %>% freq(AMX, markdown = TRUE)))
# quasiquotation
expect_output(print(septic_patients %>% freq(mo_genus(mo))))
expect_output(print(septic_patients %>% freq(mo, mo_genus(mo))))
expect_output(print(septic_patients %>% group_by(gender) %>% freq(mo_genus(mo))))
expect_output(print(septic_patients %>% group_by(gender) %>% freq(mo, mo_genus(mo))))
# top 5
expect_equal(
septic_patients %>%
freq(mo) %>%
top_freq(5) %>%
length(),
5)
# there are more than 5 lowest values
expect_gt(
septic_patients %>%
freq(mo) %>%
top_freq(-5) %>%
length(),
5)
# n has length > 1
expect_error(
septic_patients %>%
freq(mo) %>%
top_freq(n = c(1, 2))
)
# input must be freq tbl
expect_error(septic_patients %>% top_freq(1))
# charts from plot, hist and boxplot, should not raise errors
plot(freq(septic_patients, age))
hist(freq(septic_patients, age))
boxplot(freq(septic_patients, age))
boxplot(freq(dplyr::group_by(septic_patients, gender), age))
# check vector
expect_identical(septic_patients %>%
freq(age) %>%
as.vector() %>%
sort(),
septic_patients %>%
pull(age) %>%
sort())
# check format
expect_identical(septic_patients %>%
freq(age) %>%
format() %>%
apply(2, class) %>%
unname(),
rep("character", 5))
# check tibble
expect_identical(septic_patients %>%
freq(age) %>%
as_tibble() %>%
class() %>%
.[1],
"tbl_df")
expect_error(septic_patients %>% freq(nonexisting))
expect_error(septic_patients %>% select(1:10) %>% freq())
expect_error(septic_patients %>% freq(peni, oxac, clox, AMX, AMC,
ampi, pita, czol, cfep, cfur))
# (un)select columns
expect_equal(septic_patients %>% freq(hospital_id) %>% select(item) %>% ncol(),
1)
expect_equal(septic_patients %>% freq(hospital_id) %>% select(-item) %>% ncol(),
4)
# run diff
expect_output(print(
diff(freq(septic_patients$AMC),
freq(septic_patients$AMX))
))
expect_output(print(
diff(freq(septic_patients$age),
freq(septic_patients$age)) # "No differences found."
))
expect_error(print(
diff(freq(septic_patients$AMX),
"Just a string") # not a freq tbl
))
# directly on group
expect_output(print(septic_patients %>% group_by(ageplusone = as.character(age + 1)) %>% freq(ageplusone)))
})

View File

@ -144,7 +144,14 @@ knitr::kable(head(data), align = "c")
Now, let's start the cleaning and the analysis!
# Cleaning the data
Use the frequency table function `freq()` to look specifically for unique values in any variable. For example, for the `gender` variable:
We also created a package dedicated to data cleaning and checking, called the `clean` package. It gets automatically installed with the `AMR` package, so we only have to load it:
```{r lib clean, message = FALSE}
library(clean)
```
Use the frequency table function `freq()` from this `clean` package to look specifically for unique values in any variable. For example, for the `gender` variable:
```{r freq gender 1, eval = FALSE}
data %>% freq(gender) # this would be the same: freq(data$gender)

View File

@ -72,7 +72,13 @@ We can now add the interpretation of MDR-TB to our data set:
my_TB_data$mdr <- mdr_tb(my_TB_data)
```
And review the result with a frequency table:
We also created a package dedicated to data cleaning and checking, called the `clean` package. It gets automatically installed with the `AMR` package, so we only have to load it:
```{r lib clean, message = FALSE}
library(clean)
```
It contains the `freq()` function, to create a frequency table:
```{r, results = 'asis'}
freq(my_TB_data$mdr)

View File

@ -60,7 +60,17 @@ data <- WHONET %>%
mutate_at(vars(AMP_ND10:CIP_EE), as.rsi)
```
No errors or warnings, so all values are transformed succesfully. Let's check it though, with a couple of frequency tables:
No errors or warnings, so all values are transformed succesfully.
We created a package dedicated to data cleaning and checking, called the `clean` package. It gets automatically installed with the `AMR` package, so we only have to load it:
```{r lib clean, message = FALSE}
library(clean)
```
It contains the `freq()` function, to create frequency tables.
So let's check our data, with a couple of frequency tables:
```{r, results = 'asis'}
# our newly created `mo` variable

View File

@ -1,182 +0,0 @@
---
title: "How to create frequency tables"
author: "Matthijs S. Berends"
date: '`r format(Sys.Date(), "%d %B %Y")`'
output:
rmarkdown::html_vignette:
toc: true
toc_depth: 3
vignette: >
%\VignetteIndexEntry{How to create frequency tables}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
chunk_output_type: console
---
```{r setup, include = FALSE, results = 'asis'}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#",
results = 'asis',
fig.width = 7.5,
fig.height = 4.5
)
library(dplyr)
library(AMR)
```
## Introduction
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. We take the `septic_patients` dataset (included in this AMR package) as example.
## Frequencies of one variable
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 `gender` variable of the `septic_patients` dataset:
```{r, echo = TRUE}
# Any of these will work:
# freq(septic_patients$gender)
# freq(septic_patients[, "gender"])
# Using tidyverse:
# septic_patients$gender %>% freq()
# septic_patients[, "gender"] %>% freq()
# septic_patients %>% freq("gender")
# Probably the fastest and easiest:
septic_patients %>% freq(gender)
```
This immediately shows the class of the variable, its length and availability (i.e. the amount of `NA`), the amount of unique values and (most importantly) that among septic patients men are more prevalent than women.
## Frequencies of more than one variable
Multiple variables will be pasted into one variable to review individual cases, keeping a univariate frequency table.
For illustration, we could add some more variables to the `septic_patients` dataset to learn about bacterial properties:
```{r, echo = TRUE, results = 'hide'}
my_patients <- septic_patients %>% left_join_microorganisms()
```
Now all variables of the `microorganisms` dataset have been joined to the `septic_patients` dataset. The `microorganisms` dataset consists of the following variables:
```{r, echo = TRUE, results = 'markup'}
colnames(microorganisms)
```
If we compare the dimensions between the old and new dataset, we can see that these `r ncol(my_patients) - ncol(septic_patients)` variables were added:
```{r, echo = TRUE, results = 'markup'}
dim(septic_patients)
dim(my_patients)
```
So now the `genus` and `species` variables are available. A frequency table of these combined variables can be created like this:
```{r, echo = TRUE}
my_patients %>%
freq(genus, species, nmax = 15)
```
## Frequencies of numeric values
Frequency tables can be created of any input.
In case of numeric values (like integers, doubles, etc.) additional descriptive statistics will be calculated and shown into the header:
```{r, echo = TRUE}
# # get age distribution of unique patients
septic_patients %>%
distinct(patient_id, .keep_all = TRUE) %>%
freq(age, nmax = 5, header = TRUE)
```
So the following properties are determined, where `NA` values are always ignored:
* **Mean**
* **Standard deviation**
* **Coefficient of variation** (CV), the standard deviation divided by the mean
* **Mean absolute deviation** (MAD), the median of the absolute deviations from the median - a more robust statistic than the standard deviation
* **Five numbers of Tukey**, namely: the minimum, Q1, median, Q3 and maximum
* **Interquartile range** (IQR), the distance between Q1 and Q3
* **Coefficient of quartile variation** (CQV, sometimes called *coefficient of dispersion*), calculated as (Q3 - Q1) / (Q3 + Q1) using `quantile()` with `type = 6` as quantile algorithm to comply with SPSS standards
* **Outliers** (total count and unique count)
So for example, the above frequency table quickly shows the median age of patients being `r my_patients %>% distinct(patient_id, .keep_all = TRUE) %>% pull(age) %>% median(na.rm = TRUE)`.
## Frequencies of factors
To sort frequencies of factors on their levels instead of item count, use the `sort.count` parameter.
`sort.count` is `TRUE` by default. Compare this default behaviour...
```{r, echo = TRUE}
septic_patients %>%
freq(hospital_id)
```
... to this, where items are now sorted on factor levels:
```{r, echo = TRUE}
septic_patients %>%
freq(hospital_id, sort.count = FALSE)
```
All classes will be printed into the header. Variables with the new `rsi` class of this AMR package are actually ordered factors and have three classes (look at `Class` in the header):
```{r, echo = TRUE}
septic_patients %>%
freq(AMX, header = TRUE)
```
## Frequencies of dates
Frequencies of dates will show the oldest and newest date in the data, and the amount of days between them:
```{r, echo = TRUE}
septic_patients %>%
freq(date, nmax = 5, header = TRUE)
```
## Assigning a frequency table to an object
A frequency table is actually a regular `data.frame`, with the exception that it contains an additional class.
```{r, echo = TRUE}
my_df <- septic_patients %>% freq(age)
class(my_df)
```
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:
```{r, echo = TRUE}
dim(my_df)
```
## Additional parameters
### Parameter `na.rm`
With the `na.rm` parameter you can remove `NA` values from the frequency table (defaults to `TRUE`, but the number of `NA` values will always be shown into the header):
```{r, echo = TRUE}
septic_patients %>%
freq(AMX, na.rm = FALSE)
```
### Parameter `row.names`
A frequency table shows row indices. To remove them, use `row.names = FALSE`:
```{r, echo = TRUE}
septic_patients %>%
freq(hospital_id, row.names = FALSE)
```
### Parameter `markdown`
The `markdown` parameter is `TRUE` at default in non-interactive sessions, like in reports created with R Markdown. This will always print all rows, unless `nmax` is set. Without markdown (like in regular R), a frequency table would print like:
```{r, echo = TRUE, results = 'markup'}
septic_patients %>%
freq(hospital_id, markdown = FALSE)
```