Browse Source

Additionnal CRAN checks

tags/0.1.0
Maxime Wack 7 years ago
parent
commit
d73951a335
4 changed files with 83 additions and 75 deletions
  1. +1
    -0
      .Rbuildignore
  2. +6
    -7
      DESCRIPTION
  3. +23
    -0
      cran-comments.md
  4. +53
    -68
      inst/doc/desctable.html

+ 1
- 0
.Rbuildignore View File

@@ -1,2 +1,3 @@
^README\.Rmd$
^README\.html$
^cran-comments\.md$

+ 6
- 7
DESCRIPTION View File

@@ -2,14 +2,13 @@ Package: desctable
Title: Produce Descriptive and Comparative Tables Easily
Version: 0.1.0
Authors@R: person("Maxime", "Wack", email = "maximewack@free.fr", role = c("aut", "cre"))
Description: This package provides functions to easily create descriptive and
comparative tables. It makes use and integrates directly with the tidyverse family
of packages, and pipes. Tables are produced as data frames/lists of data frames
for easy manipulation after creation, and ready to be saved as csv, piped to
datatable or pander to integrate into reports.
Description: Easily create descriptive and comparative tables.
It makes use and integrates directly with the tidyverse family of packages, and pipes.
Tables are produced as data frames/lists of data frames for easy manipulation after creation,
and ready to be saved as csv, or piped to datatable or pander to integrate into reports.
Depends:
R (>= 3.2.3)
License: GPL-3 + file LICENSE
License: GPL-3
Encoding: UTF-8
LazyData: true
URL: https://github.com/maximewack/desctable
@@ -26,4 +25,4 @@ Suggests:
survival,
webshot
RoxygenNote: 6.0.1
VignetteBuilder: rmarkdown
VignetteBuilder: knitr

+ 23
- 0
cran-comments.md View File

@@ -0,0 +1,23 @@
## Test environments
* local OS X install, R 3.4.0
* ubuntu 12.04 (on travis-ci), R 3.4.0
* win-builder (devel and release)

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.

## Reverse dependencies

This is a new release, so there are no reverse dependencies.

---

* I have run R CMD check on the NUMBER downstream dependencies.
(Summary at ...).
* FAILURE SUMMARY

* All revdep maintainers were notified of the release on RELEASE DATE.

+ 53
- 68
inst/doc/desctable.html View File

@@ -231,8 +231,8 @@ Methods for reduction to a simple dataframe (<code>as.data.frame</code>, automat
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">mtcars <span class="op">%&gt;%</span>
<span class="st"> </span>desctable <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-c2abd9daa628bbe43cf7" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-c2abd9daa628bbe43cf7">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"],["32","32","32","32","32","32","32","32","32","32","32"],["20","","","","3.6","","18","","","",""],["6","","","","0.53","","1.8","","","",""],["","6","196","123","","3.3","","0","0","4","2"],["","4","205","84","","1","","1","1","1","2"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br> You need to load these two packages first (and prior to <strong>desctable</strong> for <strong>DT</strong>) if you want to use them.</p>
<p><div id="htmlwidget-bf5b0cbbc5dcaecf678c" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-bf5b0cbbc5dcaecf678c">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"],["32","32","32","32","32","32","32","32","32","32","32"],["20","","","","3.6","","18","","","",""],["6","","","","0.53","","1.8","","","",""],["","6","196","123","","3.3","","0","0","4","2"],["","4","205","84","","1","","1","1","1","2"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br> You need to load these two packages first (and prior to <strong>desctable</strong> for <strong>DT</strong>) if you want to use them.</p>
<p>Calls to <code>pander</code> and <code>datatable</code> with “regular” dataframes will not be affected by the defaults used in the package, and you can modify these defaults for <strong>desctable</strong> objects.</p>
<p>Subsequent outputs in this vignette section will use <strong>DT</strong>. The <code>datatable</code> wrapper function for desctable objects comes with some default options and formatting such as freezing the row names and table header, export buttons, and rounding of values. Both <code>pander</code> and <code>datatable</code> wrapper take a <em>digits</em> argument to set the number of decimals to show. (<code>pander</code> uses the <em>digits</em>, <em>justify</em> and <em>missing</em> arguments of <code>pandoc.table</code>, whereas <code>datatable</code> calls <code>prettyNum</code> with the <code>digits</code> parameter, and removes <code>NA</code> values. You can set <code>digits = NULL</code> if you want the full table and format it yourself)</p>
</div>
@@ -269,8 +269,8 @@ Methods for reduction to a simple dataframe (<code>as.data.frame</code>, automat
iris <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">stats =</span> stats_auto) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<div id="htmlwidget-85a0bb6f1c57228485f0" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-85a0bb6f1c57228485f0">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","    setosa","    versicolor","    virginica"],["150","150","150","150","150","50","50","50"],["","3.1","","","","33","33","33"],["","0.44","","","","","",""],["5.8","","4.3","1.3","","","",""],["1.3","","3.5","1.5","","","",""]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script>
<div id="htmlwidget-23a7ae297d869c65b646" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-23a7ae297d869c65b646">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","    setosa","    versicolor","    virginica"],["150","150","150","150","150","50","50","50"],["","3.1","","","","33","33","33"],["","0.44","","","","","",""],["5.8","","4.3","1.3","","","",""],["1.3","","3.5","1.5","","","",""]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script>
</div>
<div id="statistical-functions" class="section level3">
<h3>Statistical functions</h3>
@@ -280,8 +280,8 @@ iris <span class="op">%&gt;%</span>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">mtcars <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">stats =</span> <span class="kw">list</span>(<span class="st">&quot;N&quot;</span> =<span class="st"> </span>length, <span class="st">&quot;Mean&quot;</span> =<span class="st"> </span>mean, <span class="st">&quot;SD&quot;</span> =<span class="st"> </span>sd)) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-dec8e949997d9e9f5af5" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-dec8e949997d9e9f5af5">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"],["32","32","32","32","32","32","32","32","32","32","32"],["20","6.2","231","147","3.6","3.2","18","0.44","0.41","3.7","2.8"],["6","1.8","124","69","0.53","0.98","1.8","0.5","0.5","0.74","1.6"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>SD<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-2845bcdde667c848360b" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-2845bcdde667c848360b">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"],["32","32","32","32","32","32","32","32","32","32","32"],["20","6.2","231","147","3.6","3.2","18","0.44","0.41","3.7","2.8"],["6","1.8","124","69","0.53","0.98","1.8","0.5","0.5","0.74","1.6"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>SD<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p>The names will be used as column headers in the resulting table, and the functions will be applied safely on the variables (errors return <code>NA</code>, and for factors the function will be used on individual levels).</p>
<p>Several convenience functions are included in this package. For statistical function we have: <code>percent</code>, which prints percentages of levels in a factor, and <code>IQR</code> which re-implements <code>stats::IQR</code> but works better with <code>NA</code> values.</p>
<p>Be aware that <strong>all functions will be used on variables stripped of their <code>NA</code> values!</strong><br />
@@ -304,52 +304,37 @@ For example:</p>
<span class="st">&quot;%/Mean&quot;</span> =<span class="st"> </span>is.factor <span class="op">~</span><span class="st"> </span>percent <span class="op">|</span><span class="st"> </span>(is.normal <span class="op">~</span><span class="st"> </span>mean),
<span class="st">&quot;Median&quot;</span> =<span class="st"> </span>is.normal <span class="op">~</span><span class="st"> </span><span class="ot">NA</span> <span class="op">|</span><span class="st"> </span>median)) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-f7b2e4412c488592ee86" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-f7b2e4412c488592ee86">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","    setosa","    versicolor","    virginica"],["150","150","150","150","150","50","50","50"],["","3.1","","","","33","33","33"],["5.8","","4.3","1.3","","","",""]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>%/Mean<\/th>\n <th>Median<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-06cc58836cd8cecb2c5c" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-06cc58836cd8cecb2c5c">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","    setosa","    versicolor","    virginica"],["150","150","150","150","150","50","50","50"],["","3.1","","","","33","33","33"],["5.8","","4.3","1.3","","","",""]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>%/Mean<\/th>\n <th>Median<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p>For reference, here is the body of the <code>stats_auto</code> function in the package:</p>
<pre><code>## function(data)
<pre><code>## function (data)
## {
## data %&gt;%
## Filter(f = is.numeric) %&gt;%
## lapply(is.normal) %&gt;%
## unlist -&gt; shapiro
##
## if (length(shapiro) == 0)
## {
## normal &lt;- F
## nonnormal &lt;- F
## }
## else
## {
## any(shapiro) -&gt; normal
## any(!shapiro) -&gt; nonnormal
## }
##
## any(data %&gt;% lapply(is.factor) %&gt;% unlist) -&gt; fact
##
## if (fact &amp; normal &amp; !nonnormal)
## stats_normal(data)
## else if (fact &amp; !normal &amp; nonnormal)
## stats_nonnormal(data)
## else if (fact &amp; !normal &amp; !nonnormal)
## list(&quot;N&quot; = length,
## &quot;%&quot; = percent)
## else if (!fact &amp; normal &amp; nonnormal)
## list(&quot;N&quot; = length,
## &quot;Mean&quot; = is.normal ~ mean,
## &quot;sd&quot; = is.normal ~ sd,
## &quot;Med&quot; = is.normal ~ NA | median,
## &quot;IQR&quot; = is.normal ~ NA | IQR)
## else if (!fact &amp; normal &amp; !nonnormal)
## list(&quot;N&quot; = length,
## &quot;Mean&quot; = mean,
## &quot;sd&quot; = stats::sd)
## else if (!fact &amp; !normal &amp; nonnormal)
## list(&quot;N&quot; = length,
## &quot;Med&quot; = stats::median,
## &quot;IQR&quot; = IQR)
## else
## stats_default(data)
## shapiro &lt;- data %&gt;% Filter(f = is.numeric) %&gt;% lapply(is.normal) %&gt;%
## unlist
## if (length(shapiro) == 0) {
## normal &lt;- F
## nonnormal &lt;- F
## }
## else {
## normal &lt;- any(shapiro)
## nonnormal &lt;- any(!shapiro)
## }
## fact &lt;- any(data %&gt;% lapply(is.factor) %&gt;% unlist)
## if (fact &amp; normal &amp; !nonnormal)
## stats_normal(data)
## else if (fact &amp; !normal &amp; nonnormal)
## stats_nonnormal(data)
## else if (fact &amp; !normal &amp; !nonnormal)
## list(N = length, `%` = percent)
## else if (!fact &amp; normal &amp; nonnormal)
## list(N = length, Mean = is.normal ~ mean, sd = is.normal ~
## sd, Med = is.normal ~ NA | median, IQR = is.normal ~
## NA | IQR)
## else if (!fact &amp; normal &amp; !nonnormal)
## list(N = length, Mean = mean, sd = stats::sd)
## else if (!fact &amp; !normal &amp; nonnormal)
## list(N = length, Med = stats::median, IQR = IQR)
## else stats_default(data)
## }
## &lt;environment: namespace:desctable&gt;</code></pre>
</div>
@@ -375,8 +360,8 @@ mtcars <span class="op">%&gt;%</span>
<span class="st"> </span>dplyr<span class="op">::</span><span class="kw">mutate</span>(<span class="dt">am =</span> <span class="kw">factor</span>(am, <span class="dt">labels =</span> <span class="kw">c</span>(<span class="st">&quot;Automatic&quot;</span>, <span class="st">&quot;Manual&quot;</span>))) <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">labels =</span> mtlabels) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-1074e262cf34ad18531d" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-1074e262cf34ad18531d">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Miles/(US) gallon","Number of cylinders","Displacement (cu.in.)","Gross horsepower","Rear axle ratio","Weight (1000 lbs)","¼ mile time","V/S","<b>Transmission<\/b>","    Automatic","    Manual","Number of forward gears","Number of carburetors"],["32","32","32","32","32","32","32","32","32","19","13","32","32"],["20","","","","3.6","","18","","","59","41","",""],["6","","","","0.53","","1.8","","","","","",""],["","6","196","123","","3.3","","0","","","","4","2"],["","4","205","84","","1","","1","","","","1","2"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-9a1c731d856e167352e3" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-9a1c731d856e167352e3">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Miles/(US) gallon","Number of cylinders","Displacement (cu.in.)","Gross horsepower","Rear axle ratio","Weight (1000 lbs)","¼ mile time","V/S","<b>Transmission<\/b>","    Automatic","    Manual","Number of forward gears","Number of carburetors"],["32","32","32","32","32","32","32","32","32","19","13","32","32"],["20","","","","3.6","","18","","","59","41","",""],["6","","","","0.53","","1.8","","","","","",""],["","6","196","123","","3.3","","0","","","","4","2"],["","4","205","84","","1","","1","","","","1","2"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<hr />
</div>
</div>
@@ -667,16 +652,16 @@ iris <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">group_by</span>(Petal.Length <span class="op">&gt;</span><span class="st"> </span><span class="dv">5</span>) <span class="op">%&gt;%</span>
<span class="st"> </span>desctable <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-66baba99846df128b3c8" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-66baba99846df128b3c8">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","    setosa","    versicolor","    virginica"],["108","108","108","108","108","50","49","9"],["","3.1","","","","46","45","8.3"],["","0.48","","","","","",""],["5.5","","3.5","1","","","",""],["1","","3","1.2","","","",""],["42","42","42","42","42","0","1","41"],["","","","2.1","","0","2.4","98"],["","","","0.28","","","",""],["6.7","3","5.6","","","","",""],["0.85","0.4","0.67","","","","",""],["1.6e-15","0.69","2.1e-21","1.6e-19","2.5e-26","","",""],["wilcox.test","wilcox.test","wilcox.test","wilcox.test","fisher.test",null,null,null]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"5\">Petal.Length &gt; 5: FALSE (n=108)<\/th>\n <th colspan=\"5\">Petal.Length &gt; 5: TRUE (n=42)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-f9d71a8850e026b57ba5" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-f9d71a8850e026b57ba5">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","    setosa","    versicolor","    virginica"],["108","108","108","108","108","50","49","9"],["","3.1","","","","46","45","8.3"],["","0.48","","","","","",""],["5.5","","3.5","1","","","",""],["1","","3","1.2","","","",""],["42","42","42","42","42","0","1","41"],["","","","2.1","","0","2.4","98"],["","","","0.28","","","",""],["6.7","3","5.6","","","","",""],["0.85","0.4","0.67","","","","",""],["1.6e-15","0.69","2.1e-21","1.6e-19","2.5e-26","","",""],["wilcox.test","wilcox.test","wilcox.test","wilcox.test","fisher.test",null,null,null]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"5\">Petal.Length &gt; 5: FALSE (n=108)<\/th>\n <th colspan=\"5\">Petal.Length &gt; 5: TRUE (n=42)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p>And even on multiple nested groups:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">mtcars <span class="op">%&gt;%</span>
<span class="st"> </span>dplyr<span class="op">::</span><span class="kw">mutate</span>(<span class="dt">am =</span> <span class="kw">factor</span>(am, <span class="dt">labels =</span> <span class="kw">c</span>(<span class="st">&quot;Automatic&quot;</span>, <span class="st">&quot;Manual&quot;</span>))) <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">group_by</span>(vs, am, cyl) <span class="op">%&gt;%</span>
<span class="st"> </span>desctable <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-3ce6e496cee4b00262f9" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-3ce6e496cee4b00262f9">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","disp","hp","drat","wt","qsec","gear","carb"],["12","12","12","12","12","12","12","12"],["15","355","180","3.1","3.8","17","3","3"],["2.6","113","44","0.11","0.81","0.67","0","2"],["","","","","","","",""],["no.test","no.test","no.test","no.test","no.test","no.test","no.test","no.test"],["1","1","1","1","1","1","1","1"],["26","120","91","4.4","2.1","17","5","2"],["0","0","0","0","0","0","0","0"],["3","3","3","3","3","3","3","3"],["21","160","110","3.9","2.8","16","4","4"],["0.65","7.5","32","0.14","0.13","0.76","0.5","1"],["2","2","2","2","2","2","2","2"],["15","326","300","3.9","3.4","15","5","6"],["0.4","25","36","0.34","0.2","0.05","0","2"],["0.11","0.11","0.11","0.33","0.12","0.17","0.29","0.26"],["kruskal.test","kruskal.test","kruskal.test","kruskal.test","kruskal.test","kruskal.test","kruskal.test","kruskal.test"],["3","3","3","3","3","3","3","3"],["23","141","95","3.7","3.1","20","4","2"],["1.5","13","18","0.11","0.36","1.4","0.5","0.5"],["4","4","4","4","4","4","4","4"],["19","196","116","3.5","3.4","19","3.5","2.5"],["1.7","66","14","0.92","0.061","0.89","1","3"],["0.057","0.05","0.05","0.85","0.05","0.23","0.84","0.85"],["wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test"],["7","7","7","7","7","7","7","7"],["30","79","66","4.1","1.9","19","4","1"],["6.3","24","36","0.2","0.53","0.62","0","1"],["","","","","","","",""],["no.test","no.test","no.test","no.test","no.test","no.test","no.test","no.test"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"4\"><\/th>\n <th colspan=\"16\">vs: 0 (n=18)<\/th>\n <th colspan=\"13\">vs: 1 (n=14)<\/th>\n <\/tr>\n <tr>\n <th colspan=\"5\">am: Automatic (n=12)<\/th>\n <th colspan=\"11\">am: Manual (n=6)<\/th>\n <th colspan=\"8\">am: Automatic (n=7)<\/th>\n <th colspan=\"5\">am: Manual (n=7)<\/th>\n <\/tr>\n <tr>\n <th colspan=\"3\">cyl: 8 (n=12)<\/th>\n <th colspan=\"2\">tests<\/th>\n <th colspan=\"3\">cyl: 4 (n=1)<\/th>\n <th colspan=\"3\">cyl: 6 (n=3)<\/th>\n <th colspan=\"3\">cyl: 8 (n=2)<\/th>\n <th colspan=\"2\">tests<\/th>\n <th colspan=\"3\">cyl: 4 (n=3)<\/th>\n <th colspan=\"3\">cyl: 6 (n=4)<\/th>\n <th colspan=\"2\">tests<\/th>\n <th colspan=\"3\">cyl: 4 (n=7)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-bb00b5b1ab5e71af5352" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-bb00b5b1ab5e71af5352">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","disp","hp","drat","wt","qsec","gear","carb"],["12","12","12","12","12","12","12","12"],["15","355","180","3.1","3.8","17","3","3"],["2.6","113","44","0.11","0.81","0.67","0","2"],["","","","","","","",""],["no.test","no.test","no.test","no.test","no.test","no.test","no.test","no.test"],["1","1","1","1","1","1","1","1"],["26","120","91","4.4","2.1","17","5","2"],["0","0","0","0","0","0","0","0"],["3","3","3","3","3","3","3","3"],["21","160","110","3.9","2.8","16","4","4"],["0.65","7.5","32","0.14","0.13","0.76","0.5","1"],["2","2","2","2","2","2","2","2"],["15","326","300","3.9","3.4","15","5","6"],["0.4","25","36","0.34","0.2","0.05","0","2"],["0.11","0.11","0.11","0.33","0.12","0.17","0.29","0.26"],["kruskal.test","kruskal.test","kruskal.test","kruskal.test","kruskal.test","kruskal.test","kruskal.test","kruskal.test"],["3","3","3","3","3","3","3","3"],["23","141","95","3.7","3.1","20","4","2"],["1.5","13","18","0.11","0.36","1.4","0.5","0.5"],["4","4","4","4","4","4","4","4"],["19","196","116","3.5","3.4","19","3.5","2.5"],["1.7","66","14","0.92","0.061","0.89","1","3"],["0.057","0.05","0.05","0.85","0.05","0.23","0.84","0.85"],["wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test"],["7","7","7","7","7","7","7","7"],["30","79","66","4.1","1.9","19","4","1"],["6.3","24","36","0.2","0.53","0.62","0","1"],["","","","","","","",""],["no.test","no.test","no.test","no.test","no.test","no.test","no.test","no.test"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"4\"><\/th>\n <th colspan=\"16\">vs: 0 (n=18)<\/th>\n <th colspan=\"13\">vs: 1 (n=14)<\/th>\n <\/tr>\n <tr>\n <th colspan=\"5\">am: Automatic (n=12)<\/th>\n <th colspan=\"11\">am: Manual (n=6)<\/th>\n <th colspan=\"8\">am: Automatic (n=7)<\/th>\n <th colspan=\"5\">am: Manual (n=7)<\/th>\n <\/tr>\n <tr>\n <th colspan=\"3\">cyl: 8 (n=12)<\/th>\n <th colspan=\"2\">tests<\/th>\n <th colspan=\"3\">cyl: 4 (n=1)<\/th>\n <th colspan=\"3\">cyl: 6 (n=3)<\/th>\n <th colspan=\"3\">cyl: 8 (n=2)<\/th>\n <th colspan=\"2\">tests<\/th>\n <th colspan=\"3\">cyl: 4 (n=3)<\/th>\n <th colspan=\"3\">cyl: 6 (n=4)<\/th>\n <th colspan=\"2\">tests<\/th>\n <th colspan=\"3\">cyl: 4 (n=7)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p>In the case of nested groups (a.k.a. sub-group analysis), statistical tests are performed only between the groups of the deepest grouping level.</p>
<p>Statistical tests are automatically selected depending on the data and the grouping factor.</p>
</div>
@@ -717,8 +702,8 @@ iris <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">group_by</span>(Species) <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">tests =</span> tests_auto) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-0aca216fc3fe83c9d550" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-0aca216fc3fe83c9d550">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width"],["50","50","50","50"],["5","3.4","",""],["0.35","0.38","",""],["","","1.5","0.2"],["","","0.18","0.1"],["50","50","50","50"],["5.9","2.8","4.3",""],["0.52","0.31","0.47",""],["","","","1.3"],["","","","0.3"],["50","50","50","50"],["6.6","3","5.6",""],["0.64","0.32","0.55",""],["","","","2"],["","","","0.5"],["8.9e-22","4.5e-17","4.8e-29","3.3e-29"],["kruskal.test","ANOVA","kruskal.test","kruskal.test"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"5\">Species: setosa (n=50)<\/th>\n <th colspan=\"5\">Species: versicolor (n=50)<\/th>\n <th colspan=\"5\">Species: virginica (n=50)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-e5a5abf2b46d1348ffd3" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-e5a5abf2b46d1348ffd3">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width"],["50","50","50","50"],["5","3.4","",""],["0.35","0.38","",""],["","","1.5","0.2"],["","","0.18","0.1"],["50","50","50","50"],["5.9","2.8","4.3",""],["0.52","0.31","0.47",""],["","","","1.3"],["","","","0.3"],["50","50","50","50"],["6.6","3","5.6",""],["0.64","0.32","0.55",""],["","","","2"],["","","","0.5"],["8.9e-22","4.5e-17","4.8e-29","3.3e-29"],["kruskal.test","ANOVA","kruskal.test","kruskal.test"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"5\">Species: setosa (n=50)<\/th>\n <th colspan=\"5\">Species: versicolor (n=50)<\/th>\n <th colspan=\"5\">Species: virginica (n=50)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
</div>
<div id="list-of-statistical-test-functions" class="section level3">
<h3>List of statistical test functions</h3>
@@ -735,16 +720,16 @@ This is done using list items named as the variable and containing a single-term
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">tests =</span> <span class="kw">list</span>(<span class="dt">.auto =</span> tests_auto,
<span class="dt">Species =</span> <span class="op">~</span>chisq.test)) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-971210c985702f26d72f" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-971210c985702f26d72f">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","    setosa","    versicolor","    virginica"],["108","108","108","108","108","50","49","9"],["","3.1","","","","46","45","8.3"],["","0.48","","","","","",""],["5.5","","3.5","1","","","",""],["1","","3","1.2","","","",""],["42","42","42","42","42","0","1","41"],["","","","2.1","","0","2.4","98"],["","","","0.28","","","",""],["6.7","3","5.6","","","","",""],["0.85","0.4","0.67","","","","",""],["1.6e-15","0.69","2.1e-21","1.6e-19","2.7e-24","","",""],["wilcox.test","wilcox.test","wilcox.test","wilcox.test","chisq.test",null,null,null]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"5\">Petal.Length &gt; 5: FALSE (n=108)<\/th>\n <th colspan=\"5\">Petal.Length &gt; 5: TRUE (n=42)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-1e1d3dad311d69687101" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-1e1d3dad311d69687101">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","    setosa","    versicolor","    virginica"],["108","108","108","108","108","50","49","9"],["","3.1","","","","46","45","8.3"],["","0.48","","","","","",""],["5.5","","3.5","1","","","",""],["1","","3","1.2","","","",""],["42","42","42","42","42","0","1","41"],["","","","2.1","","0","2.4","98"],["","","","0.28","","","",""],["6.7","3","5.6","","","","",""],["0.85","0.4","0.67","","","","",""],["1.6e-15","0.69","2.1e-21","1.6e-19","2.7e-24","","",""],["wilcox.test","wilcox.test","wilcox.test","wilcox.test","chisq.test",null,null,null]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"5\">Petal.Length &gt; 5: FALSE (n=108)<\/th>\n <th colspan=\"5\">Petal.Length &gt; 5: TRUE (n=42)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean/%<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">mtcars <span class="op">%&gt;%</span>
<span class="st"> </span>dplyr<span class="op">::</span><span class="kw">mutate</span>(<span class="dt">am =</span> <span class="kw">factor</span>(am, <span class="dt">labels =</span> <span class="kw">c</span>(<span class="st">&quot;Automatic&quot;</span>, <span class="st">&quot;Manual&quot;</span>))) <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">group_by</span>(am) <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">tests =</span> <span class="kw">list</span>(<span class="dt">.default =</span> <span class="op">~</span>wilcox.test,
<span class="dt">mpg =</span> <span class="op">~</span>t.test)) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-80826537c56d00c96e57" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-80826537c56d00c96e57">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","cyl","disp","hp","drat","wt","qsec","vs","gear","carb"],["19","19","19","19","19","19","19","19","19","19"],["17","8","276","175","3.1","3.5","18","0","3","3"],["4.2","2","164","76","0.63","0.41","2","1","0","2"],["13","13","13","13","13","13","13","13","13","13"],["23","4","120","109","4.1","2.3","17","1","4","2"],["9.4","2","81","47","0.37","0.84","2.1","1","1","3"],["0.0014","0.0039","0.00055","0.046","0.00014","4.3e-05","0.27","0.36","7.6e-06","0.74"],["t.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"3\">am: Automatic (n=19)<\/th>\n <th colspan=\"3\">am: Manual (n=13)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-a5d94aa6021c0cfca4e9" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-a5d94aa6021c0cfca4e9">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","cyl","disp","hp","drat","wt","qsec","vs","gear","carb"],["19","19","19","19","19","19","19","19","19","19"],["17","8","276","175","3.1","3.5","18","0","3","3"],["4.2","2","164","76","0.63","0.41","2","1","0","2"],["13","13","13","13","13","13","13","13","13","13"],["23","4","120","109","4.1","2.3","17","1","4","2"],["9.4","2","81","47","0.37","0.84","2.1","1","1","3"],["0.0014","0.0039","0.00055","0.046","0.00014","4.3e-05","0.27","0.36","7.6e-06","0.74"],["t.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"3\">am: Automatic (n=19)<\/th>\n <th colspan=\"3\">am: Manual (n=13)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p>You might wonder why the formula expression. That is needed to capture the test name, and to provide it in the resulting table.</p>
<p>As with statistical functions, any statistical test function defined in R can be used.</p>
<p>The conditions are that the function</p>
@@ -765,8 +750,8 @@ This is done using list items named as the variable and containing a single-term
<span class="st">&quot;Q1&quot;</span> =<span class="st"> </span>. <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">quantile</span>(<span class="dt">prob =</span> .<span class="dv">25</span>),
<span class="st">&quot;Q3&quot;</span> =<span class="st"> </span>purrr<span class="op">::</span><span class="kw">partial</span>(quantile, <span class="dt">probs =</span> .<span class="dv">75</span>))) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-ffc849c01cd094ca2072" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-ffc849c01cd094ca2072">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"],["32","32","32","32","32","32","32","32","32","32","32"],["14042","1324","2179627","834278","423","361","10293","14","13","452","334"],["15","4","121","96","3.1","2.6","17","0","0","3","2"],["23","8","326","180","3.9","3.6","19","1","1","4","4"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Sum of squares<\/th>\n <th>Q1<\/th>\n <th>Q3<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-1c195140acc77e5a180b" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-1c195140acc77e5a180b">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"],["32","32","32","32","32","32","32","32","32","32","32"],["14042","1324","2179627","834278","423","361","10293","14","13","452","334"],["15","4","121","96","3.1","2.6","17","0","0","3","2"],["23","8","326","180","3.9","3.6","19","1","1","4","4"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th><\/th>\n <th>N<\/th>\n <th>Sum of squares<\/th>\n <th>Q1<\/th>\n <th>Q3<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p>In the <em>tests</em> arguments, you can also provide function definitions, functional sequences, and partial applications in the formulas:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">iris <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">group_by</span>(Species) <span class="op">%&gt;%</span>
@@ -775,8 +760,8 @@ This is done using list items named as the variable and containing a single-term
<span class="dt">Petal.Length =</span> <span class="op">~</span>. <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">oneway.test</span>(<span class="dt">var.equal =</span> T),
<span class="dt">Sepal.Length =</span> <span class="op">~</span>purrr<span class="op">::</span><span class="kw">partial</span>(oneway.test, <span class="dt">var.equal =</span> T))) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-c5d9b486d4bb4ee317d8" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-c5d9b486d4bb4ee317d8">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width"],["50","50","50","50"],["5","3.4","",""],["0.35","0.38","",""],["","","1.5","0.2"],["","","0.18","0.1"],["50","50","50","50"],["5.9","2.8","4.3",""],["0.52","0.31","0.47",""],["","","","1.3"],["","","","0.3"],["50","50","50","50"],["6.6","3","5.6",""],["0.64","0.32","0.55",""],["","","","2"],["","","","0.5"],["1.7e-31","1.4e-14","2.9e-91","3.3e-29"],["purrr::partial(oneway.test, var.equal = T)","function(f) oneway.test(f, var.equal = F)",". %>% oneway.test(var.equal = T)","kruskal.test"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"5\">Species: setosa (n=50)<\/th>\n <th colspan=\"5\">Species: versicolor (n=50)<\/th>\n <th colspan=\"5\">Species: virginica (n=50)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-28d194f20a0390abe749" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-28d194f20a0390abe749">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width"],["50","50","50","50"],["5","3.4","",""],["0.35","0.38","",""],["","","1.5","0.2"],["","","0.18","0.1"],["50","50","50","50"],["5.9","2.8","4.3",""],["0.52","0.31","0.47",""],["","","","1.3"],["","","","0.3"],["50","50","50","50"],["6.6","3","5.6",""],["0.64","0.32","0.55",""],["","","","2"],["","","","0.5"],["1.7e-31","1.4e-14","2.9e-91","3.3e-29"],["purrr::partial(oneway.test, var.equal = T)","function(f) oneway.test(f, var.equal = F)",". %>% oneway.test(var.equal = T)","kruskal.test"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"5\">Species: setosa (n=50)<\/th>\n <th colspan=\"5\">Species: versicolor (n=50)<\/th>\n <th colspan=\"5\">Species: virginica (n=50)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Mean<\/th>\n <th>sd<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p>This allows you to modulate the behavior of <code>desctable</code> in every detail, such as using paired tests, or non <em>htest</em> tests.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># This is a contrived example, which would be better solved with a dedicated function</span>
<span class="kw">library</span>(survival)
@@ -788,8 +773,8 @@ bladder <span class="op">%&gt;%</span>
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">tests =</span> <span class="kw">list</span>(<span class="dt">.default =</span> <span class="op">~</span>wilcox.test,
<span class="dt">surv =</span> <span class="op">~</span>. <span class="op">%&gt;%</span><span class="st"> </span>survdiff <span class="op">%&gt;%</span><span class="st"> </span>.<span class="op">$</span>chisq <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">pchisq</span>(<span class="dv">1</span>, <span class="dt">lower.tail =</span> F) <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">list</span>(<span class="dt">p.value =</span> .))) <span class="op">%&gt;%</span>
<span class="st"> </span>datatable</code></pre></div>
<div id="htmlwidget-c6cc859b63ce2db4fc59" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-c6cc859b63ce2db4fc59">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["id","number","size","stop","event","enum","surv"],["188","188","188","188","188","188","376"],["24","1","1","23","0","2.5",""],["24","2","2","20","1","1.5",""],["152","152","152","152","152","152","304"],["66","1","1","25","0","2.5",""],["19","2","2","28","1","1.5",""],["1.3e-56","0.62","0.32","0.17","0.02","1","0.023"],["wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test",". %>% survdiff %>% .$chisq %>% pchisq(1, lower.tail = F) %>% list(p.value = .)"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"3\">rx: 1 (n=188)<\/th>\n <th colspan=\"3\">rx: 2 (n=152)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script>
<div id="htmlwidget-8cb538454a2c895f0227" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-8cb538454a2c895f0227">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["id","number","size","stop","event","enum","surv"],["188","188","188","188","188","188","376"],["24","1","1","23","0","2.5",""],["24","2","2","20","1","1.5",""],["152","152","152","152","152","152","304"],["66","1","1","25","0","2.5",""],["19","2","2","28","1","1.5",""],["1.3e-56","0.62","0.32","0.17","0.02","1","0.023"],["wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test","wilcox.test",". %>% survdiff %>% .$chisq %>% pchisq(1, lower.tail = F) %>% list(p.value = .)"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th rowspan=\"2\"><\/th>\n <th colspan=\"3\">rx: 1 (n=188)<\/th>\n <th colspan=\"3\">rx: 2 (n=152)<\/th>\n <th colspan=\"2\">tests<\/th>\n <\/tr>\n <tr>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>N<\/th>\n <th>Med<\/th>\n <th>IQR<\/th>\n <th>p<\/th>\n <th>test<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"info":false,"search":false,"dom":"Brtip","fixedColumns":true,"paging":false,"fixedHeader":true,"buttons":["copy","excel"],"order":[],"autoWidth":false,"orderClasses":false,"columnDefs":[{"orderable":false,"targets":0}]},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script>
</div>




Loading…
Cancel
Save