[R] Sweave - have Sexpr print 3 digits when the last is 0

Elizabeth Stanny estanny at me.com
Sat Jan 30 23:50:19 CET 2010


Hi,

I want 3 digits printed even if the last one is zero with \Sexpr{}

For example: 
> ghg.06[12]
[1] 0.2501008

I want: 0.250 

What I've tried:
\Sexpr{round(ghg.06[12],3)}
0.25

\Sexpr{format(ghg.06[12])} % set options(digits=3) in earlier rnw chunk
0.25

\Sexpr{round(ghg.06[12],4} %but I want 3 not 4 digits
0.2501

Thanks in advance.

Elizabeth Stanny
epstanny at gmail.com



More information about the R-help mailing list