title: Create kable table with fully-colored background
body: <p>I'm having trouble creating a nicely formatted table in <code>R</code>. I'm 90% of the way there, but can't get all the way.</p>
  
  <p>I need to color the entire cell with a background color as seen in the example below. I read the <code>kable</code> vignette and saw that in html format, <code>background</code> does not color the whole cell. Is there a way to get around this? I tried setting it to latex instead, but the output is in latex rather than shown in the viewer. I'm also a novice <code>markdown</code> user so when I tried it there, the output was not what I was hoping for (which is simply a self-contained table).</p>
  
  <p>I've done tons of searching on SO for a solution, but I haven't been able to get it. It sure isn't easy to produce tables in <code>R</code>. Any help would be appreciated.</p>
  
  <p>Sample Data:</p>
  
  <pre><code>library(tidyverse)
  df &lt;- structure(list(Indicator = c("Var1", "Var2", "Var3", "Var4", "Var5"
  ), Sign = c(-1L, 1L, 1L, -1L, 1L), Freq = c("M", "A", "Q", "M", 
                                              "M")), row.names = c(NA, -5L), class = c("tbl_df", "tbl", "data.frame"))
  df
  # A tibble: 5 x 3
    Indicator  Sign Freq 
    &lt;chr&gt;     &lt;int&gt; &lt;chr&gt;
  1 Var1         -1 M    
  2 Var2          1 A    
  3 Var3          1 Q    
  4 Var4         -1 M    
  5 Var5          1 M 
  </code></pre>
  
  <p>Attempted code:</p>
  
  <pre><code>library(kable)
  library(kableExtra)
  df  %&gt;% 
        dplyr::rename(Trend = Freq) %&gt;%
        mutate(Indicator = cell_spec(Indicator, "html", color = "black", bold = T), 
               Trend = cell_spec(Trend, "html", color = "white", bold = T, 
                                 background = factor(Sign, c(-1, 0, 1), 
                                                     c("red", "gray", "green")))) %&gt;%
        select(Indicator, Trend) %&gt;%
        kable(align = c('l', 'c'), format = "html", escape = F) %&gt;%
        kable_styling(bootstrap_options = c("bordered", full_width = F, font_size = 16)) %&gt;% 
        row_spec(0, background = "rgb(172, 178, 152)", color = "black", font_size = 18)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/z61O3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z61O3.png" alt="Output Table"></a></p>