[R] a rounding option for \Sexpr{}?

Dieter Menne dieter.menne at menne-biomed.de
Fri Nov 19 09:02:13 CET 2010



Yihui Xie-2 wrote:
> 
> 
> Currently Sweave does not format the (especially numeric) value in
> \Sexpr{}, and I often have to round() the numbers explicitly,
> otherwise I will get more than 10 digits, which is not necessary for
> me in most cases. Is there a way to specify the number of digits to be
> kept for values in \Sexpr{}? e.g. can we make \Sexpr{} respect
> getOption('digits')?
> 
> 

Currently, Sweave does an eval on Sexpr, and that can be anything other than
a number (is mostly is, though). And you cannot define a new version of
Sexpr in latex, because Sexpr only looks like latex, but is processed before
texing.

My solution is to always do the rounding and formating in the R chunk (e.g.
with latexSN of Hmisc) to unclutter the Sexpr.

Dieter




-- 
View this message in context: http://r.789695.n4.nabble.com/a-rounding-option-for-Sexpr-tp3049872p3050001.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list