While xtable()
has a sanitize.text.function
argument which allows to sanitize strings with special charaters to stop LaTeX compilation from breaking in Sweave/knitr documents, the package does not export the function to the userspace.
How can I sanitize strings like asdf_text
outside of the xtable
context, so as to have it transformed to something like asdf\_text
? (If possible I would prefer a small, self-contained solution.)