Browse Source

Rebuilt vignette

tags/0.1.1
Maxime Wack 7 years ago
parent
commit
22faae35ea
1 changed files with 28 additions and 28 deletions
  1. +28
    -28
      inst/doc/desctable.html

+ 28
- 28
inst/doc/desctable.html View File

@@ -89,7 +89,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf

<p>Desctable is a comprehensive descriptive and comparative tables generator for R.</p>
<p>Every person doing data analysis has to create tables for descriptive summaries of data (a.k.a. Table.1), or comparative tables.</p>
<p>Many packages, such as the aptly named <strong>tableone</strong>, adress this issue. However, they often include hard-coded behaviors, have outputs not easily manipulable with standard R tools, or their syntax are out-of-style (e.g. the argument order makes them difficult to use with the pipe (<code>%&gt;%</code>)).</p>
<p>Many packages, such as the aptly named <strong>tableone</strong>, address this issue. However, they often include hard-coded behaviors, have outputs not easily manipulable with standard R tools, or their syntax are out-of-style (e.g. the argument order makes them difficult to use with the pipe (<code>%&gt;%</code>)).</p>
<p>Enter <strong>desctable</strong>, a package built with the following objectives in mind:</p>
<ul>
<li>generate descriptive and comparative statistics tables with nesting</li>
@@ -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 %&gt;%
<span class="st"> </span>desctable %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-b0f832eefba007965841" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-b0f832eefba007965841">{"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},"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-f4a5e9a58ab29f81817c" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-f4a5e9a58ab29f81817c">{"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},"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,19 +269,19 @@ Methods for reduction to a simple dataframe (<code>as.data.frame</code>, automat
iris %&gt;%
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">stats =</span> stats_auto) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<div id="htmlwidget-e95fb75910c7df15cd53" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-e95fb75910c7df15cd53">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","&nbsp;&nbsp;&nbsp;&nbsp;setosa","&nbsp;&nbsp;&nbsp;&nbsp;versicolor","&nbsp;&nbsp;&nbsp;&nbsp;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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script>
<div id="htmlwidget-c61aa24ed16bfef04c09" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-c61aa24ed16bfef04c09">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","&nbsp;&nbsp;&nbsp;&nbsp;setosa","&nbsp;&nbsp;&nbsp;&nbsp;versicolor","&nbsp;&nbsp;&nbsp;&nbsp;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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script>
</div>
<div id="statistical-functions" class="section level3">
<h3>Statistical functions</h3>
<p>Statistical functions can be any function defined in R that you want to use, such as <code>length</code> or <code>mean</code>.</p>
<p>The only condition is that they return a single numerical value. One exception is when they return a vector of length <code>1 + nlevels(x)</code> when applied to factors, as is needed for the <code>percent</code> function.</p>
<p>As mentionned above, they need to be used inside a named list, such as</p>
<p>As mentioned above, they need to be used inside a named list, such as</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">mtcars %&gt;%
<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)) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-b8ab62a32fa6b51b9cc7" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-b8ab62a32fa6b51b9cc7">{"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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-9eb0501186b468566899" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-9eb0501186b468566899">{"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},"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,8 +304,8 @@ For example:</p>
<span class="st">&quot;%/Mean&quot;</span> =<span class="st"> </span>is.factor ~<span class="st"> </span>percent |<span class="st"> </span>(is.normal ~<span class="st"> </span>mean),
<span class="st">&quot;Median&quot;</span> =<span class="st"> </span>is.normal ~<span class="st"> </span><span class="ot">NA</span> |<span class="st"> </span>median)) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-bb0cfdadd38ee12ce1a5" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-bb0cfdadd38ee12ce1a5">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","&nbsp;&nbsp;&nbsp;&nbsp;setosa","&nbsp;&nbsp;&nbsp;&nbsp;versicolor","&nbsp;&nbsp;&nbsp;&nbsp;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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-2739bac058694b601359" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-2739bac058694b601359">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","&nbsp;&nbsp;&nbsp;&nbsp;setosa","&nbsp;&nbsp;&nbsp;&nbsp;versicolor","&nbsp;&nbsp;&nbsp;&nbsp;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},"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)
## {
@@ -360,8 +360,8 @@ mtcars %&gt;%
<span class="st"> </span>dplyr::<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>))) %&gt;%
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">labels =</span> mtlabels) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-b876168a9d875a04de21" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-b876168a9d875a04de21">{"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>","&nbsp;&nbsp;&nbsp;&nbsp;Automatic","&nbsp;&nbsp;&nbsp;&nbsp;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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-f8d7e4ca6618673da939" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-f8d7e4ca6618673da939">{"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>","&nbsp;&nbsp;&nbsp;&nbsp;Automatic","&nbsp;&nbsp;&nbsp;&nbsp;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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<hr />
</div>
</div>
@@ -637,16 +637,16 @@ iris %&gt;%
<span class="st"> </span><span class="kw">group_by</span>(Petal.Length &gt;<span class="st"> </span><span class="dv">5</span>) %&gt;%
<span class="st"> </span>desctable %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-d558795d812952915b61" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-d558795d812952915b61">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","&nbsp;&nbsp;&nbsp;&nbsp;setosa","&nbsp;&nbsp;&nbsp;&nbsp;versicolor","&nbsp;&nbsp;&nbsp;&nbsp;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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-b506f7b09e48f7b738ec" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-b506f7b09e48f7b738ec">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","&nbsp;&nbsp;&nbsp;&nbsp;setosa","&nbsp;&nbsp;&nbsp;&nbsp;versicolor","&nbsp;&nbsp;&nbsp;&nbsp;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},"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 %&gt;%
<span class="st"> </span>dplyr::<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>))) %&gt;%
<span class="st"> </span><span class="kw">group_by</span>(vs, am, cyl) %&gt;%
<span class="st"> </span>desctable %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-098ad0fcbcf94cfc3ac3" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-098ad0fcbcf94cfc3ac3">{"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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-6694143fe07b891a3fba" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-6694143fe07b891a3fba">{"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},"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>
@@ -689,8 +689,8 @@ iris %&gt;%
<span class="st"> </span><span class="kw">group_by</span>(Species) %&gt;%
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">tests =</span> tests_auto) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-40b732abac1f5e8819eb" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-40b732abac1f5e8819eb">{"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.5e-28","4.5e-17","4.8e-29","3.3e-29"],[". %>% oneway.test(var.equal = F)",". %>% oneway.test(var.equal = T)","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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-308a7aadec24666a4642" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-308a7aadec24666a4642">{"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.5e-28","4.5e-17","4.8e-29","3.3e-29"],[". %>% oneway.test(var.equal = F)",". %>% oneway.test(var.equal = T)","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},"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>
@@ -707,16 +707,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> ~chisq.test)) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-1ffcb9a7d37d4c84d87f" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-1ffcb9a7d37d4c84d87f">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","&nbsp;&nbsp;&nbsp;&nbsp;setosa","&nbsp;&nbsp;&nbsp;&nbsp;versicolor","&nbsp;&nbsp;&nbsp;&nbsp;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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-7a144a5531dddb99bcfc" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-7a144a5531dddb99bcfc">{"x":{"filter":"none","class":"display","extensions":["FixedHeader","FixedColumns","Buttons"],"data":[["Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","<b>Species<\/b>","&nbsp;&nbsp;&nbsp;&nbsp;setosa","&nbsp;&nbsp;&nbsp;&nbsp;versicolor","&nbsp;&nbsp;&nbsp;&nbsp;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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">mtcars %&gt;%
<span class="st"> </span>dplyr::<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>))) %&gt;%
<span class="st"> </span><span class="kw">group_by</span>(am) %&gt;%
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">tests =</span> <span class="kw">list</span>(<span class="dt">.default =</span> ~wilcox.test,
<span class="dt">mpg =</span> ~t.test)) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-23227d362f392d2db243" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-23227d362f392d2db243">{"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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-5e41c78bb84464af26d2" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-5e41c78bb84464af26d2">{"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},"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>
@@ -737,8 +737,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>. %&gt;%<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="kw">partial</span>(quantile, <span class="dt">probs =</span> .<span class="dv">75</span>))) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-a62544ba30581c607d9a" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-a62544ba30581c607d9a">{"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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-a2350538edc1b6c19ef6" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-a2350538edc1b6c19ef6">{"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},"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 %&gt;%
<span class="st"> </span><span class="kw">group_by</span>(Species) %&gt;%
@@ -747,8 +747,8 @@ This is done using list items named as the variable and containing a single-term
<span class="dt">Petal.Length =</span> ~. %&gt;%<span class="st"> </span><span class="kw">oneway.test</span>(<span class="dt">var.equal =</span> T),
<span class="dt">Sepal.Length =</span> ~purrr::<span class="kw">partial</span>(oneway.test, <span class="dt">var.equal =</span> T))) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<p><div id="htmlwidget-99a0a761509fcbba5afb" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-99a0a761509fcbba5afb">{"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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script> <br></p>
<p><div id="htmlwidget-4d778b4ab5e727260bf8" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-4d778b4ab5e727260bf8">{"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},"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)
@@ -760,8 +760,8 @@ bladder %&gt;%
<span class="st"> </span><span class="kw">desctable</span>(<span class="dt">tests =</span> <span class="kw">list</span>(<span class="dt">.default =</span> ~wilcox.test,
<span class="dt">surv =</span> ~. %&gt;%<span class="st"> </span>survdiff %&gt;%<span class="st"> </span>.$chisq %&gt;%<span class="st"> </span><span class="kw">pchisq</span>(<span class="dv">1</span>, <span class="dt">lower.tail =</span> F) %&gt;%<span class="st"> </span><span class="kw">list</span>(<span class="dt">p.value =</span> .))) %&gt;%
<span class="st"> </span>datatable</code></pre></div>
<div id="htmlwidget-1f9b47637cad63f81e9b" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-1f9b47637cad63f81e9b">{"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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script>
<div id="htmlwidget-f78a4ec80a791cb047e3" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-f78a4ec80a791cb047e3">{"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},"callback":"function(table) {\nreturn table;\n}"},"evals":["callback"],"jsHooks":[]}</script>
</div>




Loading…
Cancel
Save