<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta name="description" content='Get group means and bootstrapped effect sizes
from the rcompanion::groupwiseMean function.
The function had to be taken separately from the package as
the dependency is failing upon install of the current package.
From the original documentation: "Calculates means and
confidence intervals for groups."
From: https://rcompanion.org/handbook/C_03.html
"For routine use, I recommend using bootstrapped confidence
intervals, particularly the BCa or percentile methods (but...)
by default, the function reports confidence intervals by the
traditional method."'><title>Get group means and CIs (rcompanion::groupwiseMean) â€” rcompanion_groupwiseMean â€¢ rempsyc</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.2.2/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.2.2/bootstrap.bundle.min.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"><!-- bootstrap-toc --><script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@v1.0.1/dist/bootstrap-toc.min.js" integrity="sha256-4veVQbu7//Lk5TSmc7YV48MxtMy98e26cf5MrgZYnwo=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- search --><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Get group means and CIs (rcompanion::groupwiseMean) â€” rcompanion_groupwiseMean"><meta property="og:description" content='Get group means and bootstrapped effect sizes
from the rcompanion::groupwiseMean function.
The function had to be taken separately from the package as
the dependency is failing upon install of the current package.
From the original documentation: "Calculates means and
confidence intervals for groups."
From: https://rcompanion.org/handbook/C_03.html
"For routine use, I recommend using bootstrapped confidence
intervals, particularly the BCa or percentile methods (but...)
by default, the function reports confidence intervals by the
traditional method."'><meta property="og:image" content="https://rempsyc.remi-theriault.com/logo.png"><!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--><!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=G-274QZTFL23"></script><script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-274QZTFL23');
</script></head><body>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>
    

    <nav class="navbar fixed-top navbar-default navbar-expand-lg bg-light"><div class="container">
    
    <a class="navbar-brand me-2" href="../index.html">rempsyc</a>

    <small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">0.1.1.3</small>

    
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="navbar" class="collapse navbar-collapse ms-3">
      <ul class="navbar-nav me-auto"><li class="nav-item">
  <a class="nav-link" href="../index.html">
    <span class="fa fa-home"></span>
     
  </a>
</li>
<li class="nav-item dropdown">
  <a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" id="dropdown-tutorials">Tutorials</a>
  <div class="dropdown-menu" aria-labelledby="dropdown-tutorials">
    <h6 class="dropdown-header" data-toc-skip>âˆš STATISTICS</h6>
    <a class="dropdown-item" href="../articles/table.html">APA tables</a>
    <a class="dropdown-item" href="../articles/t-test.html">t tests</a>
    <a class="dropdown-item" href="../articles/contrasts.html">Planned contrasts</a>
    <a class="dropdown-item" href="../articles/moderation.html">Moderations</a>
    <a class="dropdown-item" href="../articles/randomize.html">Randomization</a>
    <h6 class="dropdown-header" data-toc-skip>ðŸ“Š VISUALIZATION</h6>
    <a class="dropdown-item" href="../articles/violin.html">Violin plots</a>
    <a class="dropdown-item" href="../articles/scatter.html">Scatter plots</a>
    <a class="dropdown-item" href="../articles/circles.html">Overlapping circles</a>
    <a class="dropdown-item" href="../articles/assumptions.html">Assumptions</a>
  </div>
</li>
<li class="active nav-item">
  <a class="nav-link" href="../reference/index.html">Functions</a>
</li>
<li class="nav-item">
  <a class="nav-link" href="../news/index.html">News</a>
</li>
<li class="nav-item">
  <a class="nav-link" href="../TODOS.html">To-dos</a>
</li>
<li class="nav-item">
  <a class="nav-link" href="../articles/featured.html">Featured In</a>
</li>
      </ul><form class="form-inline my-2 my-lg-0" role="search">
        <input type="search" class="form-control me-sm-2" aria-label="Toggle navigation" name="search-input" data-search-index="../search.json" id="search-input" placeholder="Search for" autocomplete="off"></form>

      <ul class="navbar-nav"><li class="nav-item">
  <a class="external-link nav-link" href="https://lavaanExtra.remi-theriault.com/" aria-label="lavaanExtra">lavaanExtra</a>
</li>
<li class="nav-item">
  <a class="external-link nav-link" href="https://twitter.com/rempsyc" aria-label="Twitter">
    <span class="fa fa-twitter"></span>
     
  </a>
</li>
<li class="nav-item">
  <a class="external-link nav-link" href="https://github.com/rempsyc/rempsyc/" aria-label="GitHub">
    <span class="fa fa-github"></span>
     
  </a>
</li>
<li class="nav-item">
  <a class="external-link nav-link" href="https://github.com/sponsors/rempsyc" aria-label="Donate">
    <span class="fa fa-coffee"></span>
     
  </a>
</li>
      </ul></div>

    
  </div>
</nav><div class="container template-reference-topic">
<div class="row">
  <main id="main" class="col-md-9"><div class="page-header">
      <img src="../logo.png" class="logo" alt=""><h1>Get group means and CIs (rcompanion::groupwiseMean)</h1>
      <small class="dont-index">Source: <a href="https://github.com/rempsyc/rempsyc/blob/HEAD/R/rcompanion_groupwiseMean.R" class="external-link"><code>R/rcompanion_groupwiseMean.R</code></a></small>
      <div class="d-none name"><code>rcompanion_groupwiseMean.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>Get group means and bootstrapped effect sizes
from the <code><a href="https://rdrr.io/pkg/rcompanion/man/groupwiseMean.html" class="external-link">rcompanion::groupwiseMean</a></code> function.
The function had to be taken separately from the package as
the dependency is failing upon install of the current package.</p>
<p>From the original documentation: "Calculates means and
confidence intervals for groups."</p>
<p>From: https://rcompanion.org/handbook/C_03.html</p>
<p>"For routine use, I recommend using bootstrapped confidence
intervals, particularly the BCa or percentile methods (but...)
by default, the function reports confidence intervals by the
traditional method."</p>
    </div>

    <div class="section level2">
    <h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">rcompanion_groupwiseMean</span><span class="op">(</span></span>
<span>  formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  data <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  var <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  group <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  trim <span class="op">=</span> <span class="fl">0</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  conf <span class="op">=</span> <span class="fl">0.95</span>,</span>
<span>  R <span class="op">=</span> <span class="fl">5000</span>,</span>
<span>  boot <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  traditional <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  normal <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  basic <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  percentile <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  bca <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  digits <span class="op">=</span> <span class="fl">3</span>,</span>
<span>  <span class="va">...</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div class="section level2">
    <h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>
    <dl><dt>formula</dt>
<dd><p>A formula indicating the measurement variable and
the grouping variables. e.g. y ~ x1 + x2.</p></dd>


<dt>data</dt>
<dd><p>The data frame to use.</p></dd>


<dt>var</dt>
<dd><p>The measurement variable to use. The name is in double quotes.</p></dd>


<dt>group</dt>
<dd><p>The grouping variable to use. The name is in double quotes.
Multiple names are listed as a vector. (See example.)</p></dd>


<dt>trim</dt>
<dd><p>The proportion of observations trimmed from each end of the
values before the mean is calculated. (As in <code><a href="https://rdrr.io/r/base/mean.html" class="external-link">mean()</a></code>)</p></dd>


<dt>na.rm</dt>
<dd><p>If <code>TRUE</code>, <code>NA</code> values are removed during
calculations. (As in <code><a href="https://rdrr.io/r/base/mean.html" class="external-link">mean()</a></code>)</p></dd>


<dt>conf</dt>
<dd><p>The confidence interval to use.</p></dd>


<dt>R</dt>
<dd><p>The number of bootstrap replicates to use for bootstrapped
statistics.</p></dd>


<dt>boot</dt>
<dd><p>If <code>TRUE</code>, includes the mean of the bootstrapped means.
This can be used as an estimate of the mean for
the group.</p></dd>


<dt>traditional</dt>
<dd><p>If <code>TRUE</code>, includes the traditional confidence
intervals for the group means, using the t-distribution.
If <code>trim</code> is not 0,
the traditional confidence interval
will produce <code>NA</code>.
Likewise, if there are <code>NA</code> values that are not
removed, the traditional confidence interval
will produce <code>NA</code>.</p></dd>


<dt>normal</dt>
<dd><p>If <code>TRUE</code>, includes the normal confidence
intervals for the group means by bootstrap.
See <code>{boot::boot.ci}</code>.</p></dd>


<dt>basic</dt>
<dd><p>If <code>TRUE</code>, includes the basic confidence
intervals for the group means by bootstrap.
See <code>{boot::boot.ci}</code>.</p></dd>


<dt>percentile</dt>
<dd><p>If <code>TRUE</code>, includes the percentile confidence
intervals for the group means by bootstrap.
See <code>{boot::boot.ci}</code>.</p></dd>


<dt>bca</dt>
<dd><p>If <code>TRUE</code>, includes the BCa confidence
intervals for the group means by bootstrap.
See <code>{boot::boot.ci}</code>.</p></dd>


<dt>digits</dt>
<dd><p>The number of significant figures to use in output.</p></dd>


<dt>...</dt>
<dd><p>Other arguments passed to the <code>boot</code> function.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
    

<p>A data frame of requested statistics by group.</p>
    </div>
    <div class="section level2">
    <h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
    <p>The input should include either <code>formula</code> and <code>data</code>;
or <code>data</code>, <code>var</code>, and <code>group</code>. (See examples).</p>
<p></p><div class="sourceCode"><pre><code><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>     Results <span class="cf">for</span> <span class="fu">ungrouped</span> (one<span class="sc">-</span>sample) data can be obtained by either</span>

<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>     setting the right side of the formula to <span class="dv">1</span>, e.g.  y <span class="sc">~</span> <span class="dv">1</span>, or by</span>

<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>     setting \code{group<span class="ot">=</span><span class="cn">NULL</span>} when using \code{var}.</span></code></pre><p></p></div>
    </div>
    <div class="section level2">
    <h2 id="note">Note<a class="anchor" aria-label="anchor" href="#note"></a></h2>
    <p>The parsing of the formula is simplistic. The first variable on the
left side is used as the measurement variable.  The variables on the
right side are used for the grouping variables.</p>
<p></p><div class="sourceCode"><pre><code><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>     In general, it is advisable to handle \code{<span class="cn">NA</span>} values before</span>

<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>     using this function.</span>

<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>     With some options, the <span class="cf">function</span> may not handle missing values well,</span>

<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a>     or <span class="cf">in</span> the manner desired by the user.</span>

<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>     In particular, <span class="cf">if</span> \code{bca<span class="ot">=</span><span class="cn">TRUE</span>} and there are \code{<span class="cn">NA</span>} values,</span>

<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>     the <span class="cf">function</span> may fail.</span>

<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a></span>

<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a>     For a traditional method to calculate confidence intervals</span>

<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a>     on trimmed means,</span>

<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a>     see Rand Wilcox, Introduction to Robust Estimation and</span>

<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>     Hypothesis Testing.</span></code></pre><p></p></div>
    </div>
    <div class="section level2">
    <h2 id="references">References<a class="anchor" aria-label="anchor" href="#references"></a></h2>
    <p><a href="http://rcompanion.org/handbook/C_03.html" class="external-link">http://rcompanion.org/handbook/C_03.html</a></p>
    </div>
    <div class="section level2">
    <h2 id="author">Author<a class="anchor" aria-label="anchor" href="#author"></a></h2>
    <p>Salvatore Mangiafico, <a href="mailto:mangiafico@njaes.rutgers.edu">mangiafico@njaes.rutgers.edu</a></p>
    </div>

    <div class="section level2">
    <h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span><span class="co"># \donttest{</span></span></span>
<span class="r-in"><span><span class="co">### Example with formula notation</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/utils/data.html" class="external-link">data</a></span><span class="op">(</span><span class="va">mtcars</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu">rcompanion_groupwiseMean</span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html" class="external-link">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>  data         <span class="op">=</span> <span class="va">mtcars</span>,</span></span>
<span class="r-in"><span>  traditional  <span class="op">=</span> <span class="cn">FALSE</span>,</span></span>
<span class="r-in"><span>  percentile   <span class="op">=</span> <span class="cn">TRUE</span></span></span>
<span class="r-in"><span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   cyl  n Mean Conf.level Percentile.lower Percentile.upper</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   4 11 26.7       0.95             24.1             29.1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   6  7 19.7       0.95             18.7             20.7</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   8 14 15.1       0.95             13.7             16.4</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># Example with variable notation</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/utils/data.html" class="external-link">data</a></span><span class="op">(</span><span class="va">mtcars</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu">rcompanion_groupwiseMean</span><span class="op">(</span></span></span>
<span class="r-in"><span>  data <span class="op">=</span> <span class="va">mtcars</span>,</span></span>
<span class="r-in"><span>  var <span class="op">=</span> <span class="st">"mpg"</span>,</span></span>
<span class="r-in"><span>  group <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"cyl"</span>, <span class="st">"am"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>  traditional <span class="op">=</span> <span class="cn">FALSE</span>,</span></span>
<span class="r-in"><span>  percentile <span class="op">=</span> <span class="cn">TRUE</span></span></span>
<span class="r-in"><span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   cyl am  n Mean Conf.level Percentile.lower Percentile.upper</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   4  0  3 22.9       0.95             21.5             24.4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   4  1  8 28.1       0.95             25.0             30.9</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   6  0  4 19.1       0.95             18.0             20.6</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   6  1  3 20.6       0.95             19.7             21.0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   8  0 12 15.0       0.95             13.5             16.5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   8  1  2 15.4       0.95             15.0             15.8</span>
<span class="r-in"><span><span class="co"># }</span></span></span>
<span class="r-in"><span></span></span>
</code></pre></div>
    </div>
  </main><aside class="col-md-3"><nav id="toc"><h2>On this page</h2>
    </nav></aside></div>


    <footer><div class="pkgdown-footer-left">
  <p></p><p>Developed by <a href="https://remi-theriault.com" class="external-link">RÃ©mi ThÃ©riault</a>.</p>
</div>

<div class="pkgdown-footer-right">
  <p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.7.9000.</p>
</div>

    </footer></div>

  

  

  </body></html>

