On 8/20/2009 12:17 PM, Liviu Andronic wrote:
On 8/20/09, Duncan Murdoch <murd...@stats.uwo.ca> wrote:
Why not put
<<echo=FALSE>>=
options(digits=4)
@
somewhere near the top of your document?
I did so, but it has no practical effect on \Sexpr{} (which I'm
interested in, and failed to mention in the original e-mail).
With
<<echo=FALSE>>=
options(digits=4)
@
, the following
<<>>=
tmp <- pi
tmp
@
will yield
tmp <- pi
tmp
[1] 3.142
, while
\Sexpr{tmp}
will yield
3.14159265358979
and
\Sexpr{format(tmp)}
will yield
3.142
Right, \Sexpr does a simple as.character() on its argument. You might
be able to override as.character() for numeric data, but that's probably
a bad idea. So format(tmp) is probably the best choice.
Duncan Murdoch
______________________________________________
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.