Escaping LaTeX control characters in Hmisc :: latex

I have a data frame in R which, unfortunately, contains lines in it containing dollar signs. When the latex() function from the Hmisc package converts this data frame to a LaTeX table, dollar signs are not escaped. This makes LaTeX incompatible. Is there a way in Hmisc to avoid dollar signs when formatting values ​​from a data frame?

I cannot run a search and replace all dollar signs after that, because Hmisc itself adds dollar signs for empty cells.

Minimal example:

 > latex("test$test",file="") # returns: \begin{table}[!tbp] % [...] test$test\tabularnewline % [...] \end{table} # should return: \begin{table}[!tbp] % [...] test\$test\tabularnewline % [...] \end{table} 
+2
source share
1 answer

You can see the latexTranslate function, from Hmisc :

 R> latexTranslate("3%") [1] "3\\%" 
+4
source

Source: https://habr.com/ru/post/1492520/


All Articles