title: Recode summery/overview of levels before and after recoding
body: <p>I have <code>dplyr::recode</code> some factors and I am looking for a clean way to make LaTeX table where new and old categories, i.e. levels, are compared.</p>
  
  <p>Here's an illustration of the issues using <code>cyl</code> from `mtcars. First some packages,</p>
  
  <pre><code># install.packages("tidyverse", "stargazer","reporttools") 
  library(tidyverse) 
  </code></pre>
  
  <p>and the data I intend to use,</p>
  
  <pre><code>mcr &lt;- mtcars %&gt;% select(cyl) %&gt;% as_tibble() 
  mcr %&gt;% print(n=5)
  #&gt; # A tibble: 32 x 1
  #&gt;     cyl
  #&gt; * &lt;dbl&gt;
  #&gt; 1  6.00
  #&gt; 2  6.00
  #&gt; 3  4.00
  #&gt; 4  6.00
  #&gt; 5  8.00
  #&gt; # ... with 27 more rows
  </code></pre>
  
  <p>Now, I create two new factor, one with 3 categories, <code>cyl_3col</code>, and one with two, <code>cyl_is_red</code>, i.e.: </p>
  
  <pre><code>mcr_col &lt;- mcr %&gt;% as_tibble() %&gt;%
      mutate(cyl_3col = factor(cyl, levels = c(4, 6, 8),labels = c("red", "blue", "green")),
             cyl_is_red = recode(cyl_3col, .default = 'is not red', 'red' = 'is red'))
  mcr_col  %&gt;% print(n=5)
  #&gt; # A tibble: 32 x 3
  #&gt;     cyl cyl_3col cyl_is_red
  #&gt;   &lt;dbl&gt; &lt;fct&gt;    &lt;fct&gt;     
  #&gt; 1  6.00 blue     is not red
  #&gt; 2  6.00 blue     is not red
  #&gt; 3  4.00 red      is red    
  #&gt; 4  6.00 blue     is not red
  #&gt; 5  8.00 green    is not red
  #&gt; # ... with 27 more rows
  </code></pre>
  
  <p>Now, I would like to show how the categories in <code>cyl_3col</code> and <code>cyl_is_red</code> are related. </p>
  
  <p>Maybe something like this is better,</p>
  
  <pre><code>#&gt; cyl_is_red  cyl_3col 
  #&gt; is red               
  #&gt;             red      
  #&gt; is not red           
  #&gt;             blue     
  #&gt;             green    
  </code></pre>
  
  <p>possible something like this, I imagine the <code>is not red</code> category spanning two rows with <code>\multirow{}</code> or something like it. </p>
  
  <pre><code>#&gt;  cyl_3col   cyl_is_red
  #&gt; 1 red       is red    
  #&gt; 2 blue      is not red
  #&gt; 3 green     ----------
  </code></pre>
  
  <p>using <a href="/questions/tagged/stargazer" class="post-tag" title="show questions tagged &#39;stargazer&#39;" rel="tag">stargazer</a> or possibly some other TeX tool. I am very open as to how I can best show the recoding. I assume there's some smart way to code this thought out by someone who came before me?</p>
  
  <p>I've used something like <code>mcr_col %&gt;% count(cyl_3col, cyl_is_red)</code> for now, but I don't think it's really working. </p>