title: knitr::kable does not escape special character $ correctly in the string data when knitring to html (to PDF is okay)
body: <p>With $-signs in the data knitr::kable is confused. The data are shown as if they were meant to be in math-mode. Funny enough, knitr to PDF does not show this effect.</p>
  <p>I tried to escape the dollar-sign with backslash (even tried to use up to four backslashes), to use chunk-option &quot;markup&quot; for results, to set off auto-escaping in kable, or to use Hex-Unicode instead of the character. Nothing helped.
  Any further ideas are very welcome.</p>
  <p>I use Rstudio to knitr either as HTML or as PDF. Here is my MWE from my *.Rmd:</p>
  <pre><code>---
  title: MWE knitr::kable does not escape special character $ correctly in the string data when knitring to html (to PDF is okay)
  output:
    html_document:
      df_print: paged
    pdf_document: default
  ---
  
      ```{r UNESCAPED , eval=TRUE ,  echo=FALSE , tidy=TRUE, message=FALSE , warning=FALSE , results='asis'}
      
      
      
      library (&quot;knitr&quot;)
      library(&quot;kableExtra&quot;)#not needed but helpful to see the problem
      library(&quot;tidyverse&quot;)#not needed but helpful to see the problem
      
      data &lt;- data.frame(stringVar=c(&quot;$1$&quot;,&quot;$2$&quot;))
      #escaping $ shows error message:
      #data &lt;- data.frame(stringVar=c(&quot;\$1\$&quot;,&quot;\$2\$&quot;))
      
      if (knitr::is_html_output())
      {
        knitr::kable(data, row.names = TRUE, format = &quot;html&quot; , escape = TRUE)%&gt;% #same effect with escape=FALSE
          kable_styling( &quot;striped&quot;)#same effect without kable_styling
        #last cell is rendered in math mode
      }else{
        knitr::kable(data, format=&quot;latex&quot;, longtable=T, booktabs = T, linesep = &quot;&quot;, row.names = TRUE, escape = TRUE) %&gt;%
          kable_styling(latex_options =c(&quot;striped&quot;)) 
        #last cell is rendered as expected
      }#end of if
      
      
      ```
  </code></pre>