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
}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to