<!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="Adds zeros for catches of species that were not captured in a sampling event but were captured in at least one other sampling event (i.e., adds zeros to the data.frame for capture events where a species was not observed)."><title>Adds zeros for catches of species not collected in some sampling events. — addZeroCatch • FSA</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="Adds zeros for catches of species not collected in some sampling events. — addZeroCatch"><meta property="og:description" content="Adds zeros for catches of species that were not captured in a sampling event but were captured in at least one other sampling event (i.e., adds zeros to the data.frame for capture events where a species was not observed)."><meta property="og:image" content="https://fishr-core-team.github.io/FSA/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]--></head><body>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>
    

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

    <small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Released version">0.9.5</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="active nav-item">
  <a class="nav-link" href="../reference/index.html">Reference</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="nav-link" href="../news/index.html">
    <span class="fa fa-newspaper"></span>
     
  </a>
</li>
<li class="nav-item">
  <a class="nav-link" href="../index.html">
    <span class="fa fa-home fa"></span>
     
  </a>
</li>
<li class="nav-item">
  <a class="external-link nav-link" href="https://github.com/fishR-Core-Team/FSA">
    <span class="fa fa-github fa"></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>Adds zeros for catches of species not collected in some sampling events.</h1>
      <small class="dont-index">Source: <a href="https://github.com/fishR-Core-Team/FSA/blob/HEAD/R/addZeroCatch.R" class="external-link"><code>R/addZeroCatch.R</code></a></small>
      <div class="d-none name"><code>addZeroCatch.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>Adds zeros for catches of species that were not captured in a sampling event but were captured in at least one other sampling event (i.e., adds zeros to the data.frame for capture events where a species was not observed).</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">addZeroCatch</span><span class="op">(</span><span class="va">df</span>, <span class="va">eventvar</span>, <span class="va">specvar</span>, <span class="va">zerovar</span>, na.rm <span class="op">=</span> <span class="cn">TRUE</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>df</dt>
<dd><p>A data.frame that contains the capture summary data as described in the details.</p></dd>


<dt>eventvar</dt>
<dd><p>A string for the variable that identifies unique capture events.</p></dd>


<dt>specvar</dt>
<dd><p>A string or vector of strings for the variable(s) that identify the “species” (if multiple variables, could be species, sex, and life stage, for example) captured. See examples.</p></dd>


<dt>zerovar</dt>
<dd><p>A string or vector of strings for the variable(s) that should be set equal to zero. See details and examples.</p></dd>


<dt>na.rm</dt>
<dd><p>A logical that indicates if rows where <code>specvar</code> that are <code>NA</code> should be removed after adding the zeros. See details.</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 with the same structure as <code>df</code> but with rows of zero observation data appended.</p>
    </div>
    <div class="section level2">
    <h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
    <p>The data.frame in <code>df</code> must contain a column that identifies a unique capture event (given in <code>eventvar</code>), a column with the name for the species captured (given in <code>specvar</code>), and a column that contains the number of that species captured (potentially given to <code>zerovar</code>; see details). All sampling event and species combinations where catch information does not exist is identified and a new data.frame that contains a zero for the catch for all of these combinations is created. This new data.frame is appended to the original data.frame to construct a data.frame that contains complete catch information -- i.e., including zeros for species in events where that species was not captured.</p>
<p>The data.frame may contain other information related to the catch, such as number of recaptured fish, number of fish released, etc. These additional variables can be included in <code>zerovar</code> so that zeros will be added to these variables as well (e.g., if the catch of the species is zero, then the number of recaptures must also be zero). All variables not given in <code>eventvar</code>, <code>specvar</code>, or <code>zerovar</code> will be assumed to be related to <code>eventvar</code> and <code>specvar</code> (e.g., date, gear type, and habitat) and, thus, will be repeated with these variables.</p>
<p>In situations where no fish were captured in some events, the <code>df</code> may contain rows that have a value for <code>eventvar</code> but not for <code>specvar</code>. These rows are important because zeros need to be added for each observed species for these events. However, in these situations, a <code>&lt;NA&gt;</code> species will appear in the resulting data.frame. It is unlikely that these “missing” species are needed so they will be removed if <code>na.rm=TRUE</code> (DEFAULT) is used.</p>
<p>One should test the results of this function by creating a frequency table of the <code>eventvar</code> or <code>specvar</code>. In either case, the table should contain the same value in each cell of the table. See the examples.</p>
    </div>
    <div class="section level2">
    <h2 id="note">Note<a class="anchor" aria-label="anchor" href="#note"></a></h2>
    <p>An error will be returned if either <code>specvar</code> or <code>eventvar</code> are factors with any <code>NA</code> levels. This usually arises if the data.frame was subsetted/filtered prior to using <code>addZeroCatch</code>. See <code><a href="https://rdrr.io/r/base/droplevels.html" class="external-link">droplevels</a></code> for descriptions of how to drop unused levels.</p>
    </div>
    <div class="section level2">
    <h2 id="ifar-chapter">IFAR Chapter<a class="anchor" aria-label="anchor" href="#ifar-chapter"></a></h2>
    <p>2-Basic Data Manipulations</p>
    </div>
    <div class="section level2">
    <h2 id="references">References<a class="anchor" aria-label="anchor" href="#references"></a></h2>
    <p>Ogle, D.H. 2016. <a href="https://fishr-core-team.github.io/fishR/pages/books.html#introductory-fisheries-analyses-with-r" class="external-link">Introductory Fisheries Analyses with R</a>. Chapman &amp; Hall/CRC, Boca Raton, FL.</p>
    </div>
    <div class="section level2">
    <h2 id="see-also">See also<a class="anchor" aria-label="anchor" href="#see-also"></a></h2>
    <div class="dont-index"><p><code>complete</code> in <span class="pkg">tidyr</span> package.</p></div>
    </div>
    <div class="section level2">
    <h2 id="author">Author<a class="anchor" aria-label="anchor" href="#author"></a></h2>
    <p>Derek H. Ogle, <a href="mailto:DerekOgle51@gmail.com">DerekOgle51@gmail.com</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">## Example Data #1 (some nets missing some fish, ancillary net data)</span></span></span>
<span class="r-in"><span><span class="va">df1</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>net<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="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">2</span>,<span class="fl">2</span>,<span class="fl">3</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>                  eff<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="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>                  species<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">"BKT"</span>,<span class="st">"LKT"</span>,<span class="st">"RBT"</span>,<span class="st">"BKT"</span>,<span class="st">"LKT"</span>,<span class="st">"RBT"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>                  catch<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="fl">3</span>,<span class="fl">4</span>,<span class="fl">5</span>,<span class="fl">5</span>,<span class="fl">4</span>,<span class="fl">3</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df1</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   net eff species catch</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   1   1     BKT     3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   1   1     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   1   1     RBT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   2   1     BKT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   2   1     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   3   1     RBT     3</span>
<span class="r-in"><span><span class="co"># not all 1s</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">net</span><span class="op">+</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> net BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   1   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   2   1   1   0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   3   0   0   1</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">df1mod1</span> <span class="op">&lt;-</span> <span class="fu">addZeroCatch</span><span class="op">(</span><span class="va">df1</span>,<span class="st">"net"</span>,<span class="st">"species"</span>,zerovar<span class="op">=</span><span class="st">"catch"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df1mod1</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   net eff species catch</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   1   1     BKT     3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   1   1     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   1   1     RBT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   2   1     BKT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   2   1     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   3   1     RBT     3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 7   3   1     BKT     0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8   3   1     LKT     0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 9   2   1     RBT     0</span>
<span class="r-in"><span><span class="co"># check, should all be 3</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">net</span>,data<span class="op">=</span><span class="va">df1mod1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> net</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1 2 3 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3 3 3 </span>
<span class="r-in"><span><span class="co"># check, should all be 1</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">net</span><span class="op">+</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df1mod1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> net BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   1   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   2   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   3   1   1   1</span>
<span class="r-in"><span><span class="co"># correct mean/sd of catches</span></span></span>
<span class="r-in"><span><span class="fu"><a href="Summarize.html">Summarize</a></span><span class="op">(</span><span class="va">catch</span><span class="op">~</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df1mod1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   species n     mean       sd min  Q1 median Q3 max percZero</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1     BKT 3 2.666667 2.516611   0 1.5      3  4   5 33.33333</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2     LKT 3 2.666667 2.309401   0 2.0      4  4   4 33.33333</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3     RBT 3 2.666667 2.516611   0 1.5      3  4   5 33.33333</span>
<span class="r-in"><span><span class="co"># incorrect mean/sd of catches (no zeros)</span></span></span>
<span class="r-in"><span><span class="fu"><a href="Summarize.html">Summarize</a></span><span class="op">(</span><span class="va">catch</span><span class="op">~</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   species n mean       sd min  Q1 median  Q3 max</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1     BKT 2    4 1.414214   3 3.5      4 4.5   5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2     LKT 2    4 0.000000   4 4.0      4 4.0   4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3     RBT 2    4 1.414214   3 3.5      4 4.5   5</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># Same as example 1 but with no ancillary data specific to the net number</span></span></span>
<span class="r-in"><span><span class="va">df2</span> <span class="op">&lt;-</span> <span class="va">df1</span><span class="op">[</span>,<span class="op">-</span><span class="fl">2</span><span class="op">]</span></span></span>
<span class="r-in"><span><span class="va">df2</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   net species catch</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   1     BKT     3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   1     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   1     RBT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   2     BKT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   2     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   3     RBT     3</span>
<span class="r-in"><span><span class="va">df1mod2</span> <span class="op">&lt;-</span> <span class="fu">addZeroCatch</span><span class="op">(</span><span class="va">df2</span>,<span class="st">"net"</span>,<span class="st">"species"</span>,zerovar<span class="op">=</span><span class="st">"catch"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df1mod2</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   net species catch</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   1     BKT     3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   1     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   1     RBT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   2     BKT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   2     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   3     RBT     3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 7   3     BKT     0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8   3     LKT     0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 9   2     RBT     0</span>
<span class="r-in"><span><span class="co"># check, should all be 1</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">net</span><span class="op">+</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df1mod2</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> net BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   1   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   2   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   3   1   1   1</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co">## Example Data #3 (All nets have same species ... no zeros needed)</span></span></span>
<span class="r-in"><span><span class="va">df3</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>net<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="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">2</span>,<span class="fl">2</span>,<span class="fl">2</span>,<span class="fl">3</span>,<span class="fl">3</span>,<span class="fl">3</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>                  eff<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="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span>,<span class="fl">1</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>                  species<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">"BKT"</span>,<span class="st">"LKT"</span>,<span class="st">"RBT"</span>,<span class="st">"BKT"</span>,<span class="st">"LKT"</span>,</span></span>
<span class="r-in"><span>                            <span class="st">"RBT"</span>,<span class="st">"BKT"</span>,<span class="st">"LKT"</span>,<span class="st">"RBT"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>                  catch<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="fl">3</span>,<span class="fl">4</span>,<span class="fl">5</span>,<span class="fl">5</span>,<span class="fl">4</span>,<span class="fl">3</span>,<span class="fl">3</span>,<span class="fl">2</span>,<span class="fl">7</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df3</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   net eff species catch</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   1   1     BKT     3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   1   1     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   1   1     RBT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   2   1     BKT     5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   2   1     LKT     4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   2   1     RBT     3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 7   3   1     BKT     3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8   3   1     LKT     2</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 9   3   1     RBT     7</span>
<span class="r-in"><span><span class="co"># should all be 1 for this example</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">net</span><span class="op">+</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df3</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> net BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   1   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   2   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   3   1   1   1</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># should receive a warning and table should still all be 1</span></span></span>
<span class="r-in"><span><span class="va">df3mod1</span> <span class="op">&lt;-</span> <span class="fu">addZeroCatch</span><span class="op">(</span><span class="va">df3</span>,<span class="st">"net"</span>,<span class="st">"species"</span>,zerovar<span class="op">=</span><span class="st">"catch"</span><span class="op">)</span></span></span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span class="warning">Warning: </span>All 'eventvar' have all species in 'specvar'; thus, there are no</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> zeros to add. The original data.frame was returned.</span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">net</span><span class="op">+</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df3mod1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> net BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   1   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   2   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   3   1   1   1</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co">## Example Data #4 (another variable that needs zeros)</span></span></span>
<span class="r-in"><span><span class="va">df4</span> <span class="op">&lt;-</span> <span class="va">df1</span></span></span>
<span class="r-in"><span><span class="va">df4</span><span class="op">$</span><span class="va">recaps</span> <span class="op">&lt;-</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="fl">0</span>,<span class="fl">0</span>,<span class="fl">0</span>,<span class="fl">1</span>,<span class="fl">2</span>,<span class="fl">1</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df4</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   net eff species catch recaps</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   1   1     BKT     3      0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   1   1     LKT     4      0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   1   1     RBT     5      0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   2   1     BKT     5      1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   2   1     LKT     4      2</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   3   1     RBT     3      1</span>
<span class="r-in"><span><span class="co"># not all 1s</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">net</span><span class="op">+</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df4</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> net BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   1   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   2   1   1   0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   3   0   0   1</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">df4mod1</span> <span class="op">&lt;-</span> <span class="fu">addZeroCatch</span><span class="op">(</span><span class="va">df4</span>,<span class="st">"net"</span>,<span class="st">"species"</span>,zerovar<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">"catch"</span>,<span class="st">"recaps"</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="co"># note zeros in both variables</span></span></span>
<span class="r-in"><span><span class="va">df4mod1</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   net eff species catch recaps</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   1   1     BKT     3      0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   1   1     LKT     4      0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   1   1     RBT     5      0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   2   1     BKT     5      1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   2   1     LKT     4      2</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   3   1     RBT     3      1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 7   3   1     BKT     0      0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8   3   1     LKT     0      0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 9   2   1     RBT     0      0</span>
<span class="r-in"><span><span class="co"># check, should all be 1</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">net</span><span class="op">+</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df4mod1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> net BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   1   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   2   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   3   1   1   1</span>
<span class="r-in"><span><span class="co"># observe difference from next</span></span></span>
<span class="r-in"><span><span class="fu"><a href="Summarize.html">Summarize</a></span><span class="op">(</span><span class="va">catch</span><span class="op">~</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df4</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   species n mean       sd min  Q1 median  Q3 max</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1     BKT 2    4 1.414214   3 3.5      4 4.5   5</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2     LKT 2    4 0.000000   4 4.0      4 4.0   4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3     RBT 2    4 1.414214   3 3.5      4 4.5   5</span>
<span class="r-in"><span><span class="fu"><a href="Summarize.html">Summarize</a></span><span class="op">(</span><span class="va">catch</span><span class="op">~</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df4mod1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   species n     mean       sd min  Q1 median Q3 max percZero</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1     BKT 3 2.666667 2.516611   0 1.5      3  4   5 33.33333</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2     LKT 3 2.666667 2.309401   0 2.0      4  4   4 33.33333</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3     RBT 3 2.666667 2.516611   0 1.5      3  4   5 33.33333</span>
<span class="r-in"><span><span class="co"># observe difference from next</span></span></span>
<span class="r-in"><span><span class="fu"><a href="Summarize.html">Summarize</a></span><span class="op">(</span><span class="va">recaps</span><span class="op">~</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df4</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   species n mean        sd min   Q1 median   Q3 max percZero</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1     BKT 2  0.5 0.7071068   0 0.25    0.5 0.75   1       50</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2     LKT 2  1.0 1.4142136   0 0.50    1.0 1.50   2       50</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3     RBT 2  0.5 0.7071068   0 0.25    0.5 0.75   1       50</span>
<span class="r-in"><span><span class="fu"><a href="Summarize.html">Summarize</a></span><span class="op">(</span><span class="va">recaps</span><span class="op">~</span><span class="va">species</span>,data<span class="op">=</span><span class="va">df4mod1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   species n      mean        sd min Q1 median  Q3 max percZero</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1     BKT 3 0.3333333 0.5773503   0  0      0 0.5   1 66.66667</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2     LKT 3 0.6666667 1.1547005   0  0      0 1.0   2 66.66667</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3     RBT 3 0.3333333 0.5773503   0  0      0 0.5   1 66.66667</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co">## Example Data #5 (two "specvar"s)</span></span></span>
<span class="r-in"><span><span class="va">df5</span> <span class="op">&lt;-</span> <span class="va">df1</span></span></span>
<span class="r-in"><span><span class="va">df5</span><span class="op">$</span><span class="va">sex</span> <span class="op">&lt;-</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">"m"</span>,<span class="st">"m"</span>,<span class="st">"f"</span>,<span class="st">"m"</span>,<span class="st">"f"</span>,<span class="st">"f"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df5</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   net eff species catch sex</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   1   1     BKT     3   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   1   1     LKT     4   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   1   1     RBT     5   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   2   1     BKT     5   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   2   1     LKT     4   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   3   1     RBT     3   f</span>
<span class="r-in"><span><span class="co"># not all 1s</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">sex</span><span class="op">+</span><span class="va">species</span><span class="op">+</span><span class="va">net</span>,data<span class="op">=</span><span class="va">df5</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> , , net = 1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sex BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   f   0   0   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   m   1   1   0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> , , net = 2</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sex BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   f   0   1   0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   m   1   0   0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> , , net = 3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sex BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   f   0   0   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   m   0   0   0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">df5mod1</span> <span class="op">&lt;-</span> <span class="fu">addZeroCatch</span><span class="op">(</span><span class="va">df5</span>,<span class="st">"net"</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">"species"</span>,<span class="st">"sex"</span><span class="op">)</span>,zerovar<span class="op">=</span><span class="st">"catch"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df5mod1</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    net eff species catch sex</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1    1   1     BKT     3   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2    1   1     LKT     4   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3    1   1     RBT     5   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4    2   1     BKT     5   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5    2   1     LKT     4   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6    3   1     RBT     3   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 7    1   1     BKT     0   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8    2   1     BKT     0   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 9    3   1     BKT     0   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 10   1   1     LKT     0   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 11   3   1     LKT     0   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 12   2   1     RBT     0   f</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 13   3   1     BKT     0   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 14   2   1     LKT     0   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 15   3   1     LKT     0   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 16   1   1     RBT     0   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 17   2   1     RBT     0   m</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 18   3   1     RBT     0   m</span>
<span class="r-in"><span><span class="co"># all 1s</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/stats/xtabs.html" class="external-link">xtabs</a></span><span class="op">(</span><span class="op">~</span><span class="va">sex</span><span class="op">+</span><span class="va">species</span><span class="op">+</span><span class="va">net</span>,data<span class="op">=</span><span class="va">df5mod1</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> , , net = 1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sex BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   f   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   m   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> , , net = 2</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sex BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   f   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   m   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> , , net = 3</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    species</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sex BKT LKT RBT</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   f   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   m   1   1   1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/utils/str.html" class="external-link">str</a></span><span class="op">(</span><span class="va">df5mod1</span><span class="op">)</span> </span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 'data.frame':	18 obs. of  5 variables:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>  $ net    : num  1 1 1 2 2 3 1 2 3 1 ...</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>  $ eff    : num  1 1 1 1 1 1 1 1 1 1 ...</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>  $ species: chr  "BKT" "LKT" "RBT" "BKT" ...</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>  $ catch  : num  3 4 5 5 4 3 0 0 0 0 ...</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>  $ sex    : chr  "m" "m" "f" "m" ...</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co">## Example Data #6 (three "specvar"s)</span></span></span>
<span class="r-in"><span><span class="va">df6</span> <span class="op">&lt;-</span> <span class="va">df5</span></span></span>
<span class="r-in"><span><span class="va">df6</span><span class="op">$</span><span class="va">size</span> <span class="op">&lt;-</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">"lrg"</span>,<span class="st">"lrg"</span>,<span class="st">"lrg"</span>,<span class="st">"sm"</span>,<span class="st">"lrg"</span>,<span class="st">"sm"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df6</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   net eff species catch sex size</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   1   1     BKT     3   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   1   1     LKT     4   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   1   1     RBT     5   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4   2   1     BKT     5   m   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   2   1     LKT     4   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6   3   1     RBT     3   f   sm</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">df6mod1</span> <span class="op">&lt;-</span> <span class="fu">addZeroCatch</span><span class="op">(</span><span class="va">df6</span>,<span class="st">"net"</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">"species"</span>,<span class="st">"sex"</span>,<span class="st">"size"</span><span class="op">)</span>,zerovar<span class="op">=</span><span class="st">"catch"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">df6mod1</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    net eff species catch sex size</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1    1   1     BKT     3   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2    1   1     LKT     4   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3    1   1     RBT     5   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4    2   1     BKT     5   m   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5    2   1     LKT     4   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6    3   1     RBT     3   f   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 7    1   1     BKT     0   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8    2   1     BKT     0   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 9    3   1     BKT     0   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 10   1   1     LKT     0   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 11   3   1     LKT     0   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 12   2   1     RBT     0   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 13   3   1     RBT     0   f  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 14   2   1     BKT     0   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 15   3   1     BKT     0   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 16   2   1     LKT     0   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 17   3   1     LKT     0   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 18   1   1     RBT     0   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 19   2   1     RBT     0   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 20   3   1     RBT     0   m  lrg</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 21   1   1     BKT     0   f   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 22   2   1     BKT     0   f   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 23   3   1     BKT     0   f   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 24   1   1     LKT     0   f   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 25   2   1     LKT     0   f   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 26   3   1     LKT     0   f   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 27   1   1     RBT     0   f   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 28   2   1     RBT     0   f   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 29   1   1     BKT     0   m   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 30   3   1     BKT     0   m   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 31   1   1     LKT     0   m   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 32   2   1     LKT     0   m   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 33   3   1     LKT     0   m   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 34   1   1     RBT     0   m   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 35   2   1     RBT     0   m   sm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 36   3   1     RBT     0   m   sm</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="http://derekogle.com" class="external-link">Derek H. Ogle</a>, Jason C. Doll, A. Powell Wheeler, Alexis Dinno.</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.</p>
</div>

    </footer></div>

  

  

  </body></html>

