[R] Sweave and backslashes
Dieter Menne
dieter.menne at menne-biomed.de
Fri Feb 6 08:24:52 CET 2009
cls59 <sharpsteen <at> mac.com> writes:
> I am an avid Sweave user and I am trying to pretty print floating point
> numbers for latex output. For example in my document, I would like:
>
> 4.2\cdot 10^-{8}
>
> Instead of:
>
> 4.2e-08
>
> The Hmisc package has a nice function for doing this- but Hmisc has a ton of
> dependencies and has proved very unportable to the various machines I work
> on. So, I set out to write my own function that just uses basic R commands,
> it looks like this:
I have my special version of it in the library :
"latexSNdouble" <-
function (val)
{
# special copy of Hmisc latexSN with \\\\
require(Hmisc)
x <- format(val)
x <- sedit(val, c("e+00", "e-0*", "e-*", "e+0*", "e+*"), c("",
"\\\\!\\\\times\\\\!10^{-*}",
"\\\\!\\\\times\\\\!10^{-*}",
"\\\\!\\\\times\\\\!10^{*}",
"\\\\!\\\\times\\\\!10^{*}"))
x
}
More information about the R-help
mailing list