title: Conditional Cell Formatting using KableExtra in R
body: <p>I'm trying to format cell's within a column using <code>cell_spec</code> in the <code>KableExtra</code> library. My data and code looks like this:</p>
  <pre><code>df&lt;-data.frame(Category=c(&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;),Q1=c(46540.6541,4779.1654,798984.648,987454.144586),Q2=c(98742.06543,78993.0641,6418.016,48974.041684),QoQ=c(&quot;1.02%&quot;,&quot;8.05%&quot;,&quot;5.04&quot;,&quot;6.87&quot;))
  df$QoQ&lt;-ifelse(
    df$QoQ &gt; 0.00,
    cell_spec(df$QoQ, color = &quot;green&quot;, bold = T),
    cell_spec(df$QoQ, color = &quot;red&quot;, bold = T))
  kbl(df)
  </code></pre>
  <p>When I execute the code above, the table's QoQ column returns the following: <code>&lt;span style=&quot; font-weight: bold;    color: green !important;&quot; &gt;1.02%&lt;/span&gt;</code>. I suspect this is because I'm filtering the values numerically but my data class is character. My question is, can I keep my data as is, meaning I keep the % sign in the QoQ column, and still write a conditional statement where if the QoQ cell is greater than 0.00% then it is green, otherwise red?</p>