[R] Sweave: printing an underscore in the output from an R command

David Epstein David.Epstein at warwick.ac.uk
Mon Sep 2 17:38:19 CEST 2013


I am working with Sweave and would like to print out into my latex document the result of the R command
version$platform
So what I first tried in my .Rnw document was \Sexpr{print(version$platform)}.

However, the output from this command is the string "x86_64-apple-darwin10.8.0" (without the quotes). This contains an underscore, which is a special character in tex and so I get an error message from latex.

I can get round this by using sub to replace underscore with a space, but I would like to know how to print the underscore if I really wanted to do so.



More information about the R-help mailing list