Elizabeth Stanny
2010-Jan-30 22:50 UTC
[R] Sweave - have Sexpr print 3 digits when the last is 0
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
Jorge Ivan Velez
2010-Jan-31 00:05 UTC
[R] Sweave - have Sexpr print 3 digits when the last is 0
Hi Elizabeth, Try using sprintf (?sprintf) instead of round(). HTH, Jorge On Sat, Jan 30, 2010 at 5:50 PM, Elizabeth Stanny <> wrote:> 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@gmail.com > > ______________________________________________ > 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. >[[alternative HTML version deleted]]
Reasonably Related Threads
- Hmisc, Design, summary.Design plot- changing confidence intervals, adding color or decreasing font size
- problem with coding for 'optim' in R
- Sweave processes \Sexpr in commented LaTeX source (2.3.1patched and 2.4.0)
- Sweave processes \Sexpr in commented LaTeX source (2.3.1patched and 2.4.0)
- Top level \Sexpr and R CMD check