[R] Decimal places

Robert Mcfadden robert-mcfadden at o2.pl
Wed May 24 23:08:20 CEST 2006


Thank you very much. Round(x, digids=2) works perfect.
Rob

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley w stats.ox.ac.uk] 
Sent: Wednesday, May 24, 2006 10:47 PM
To: Robert Mcfadden
Cc: r-help w stat.math.ethz.ch
Subject: Re: [R] Decimal places

On Wed, 24 May 2006, Robert Mcfadden wrote:

> Hello,
>
> I would like to force R to print 2 decimal places. I use options(digits=2)
> but as far as I know it prints significant digits so in certain cases is
> more then 2.
>
> Is there other way to do it?

?round, possibly

format(rounf(x, 2), nsmall = 2)

if you want exactly 2 decimal places.

-- 
Brian D. Ripley,                  ripley w stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list