From ripley@stats.ox.ac.uk  Tue Aug  6 07:33:44 2002
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Tue, 6 Aug 2002 07:33:44 +0100 (BST)
Subject: options(digits) (PR#1879)
In-Reply-To: <200208052339.BAA19235@pubhealth.ku.dk>
Message-ID: <Pine.LNX.4.31.0208060726530.29814-100000@gannet.stats>

On Tue, 6 Aug 2002 gordong@epa.nsw.gov.au wrote:

> Apologies for bothering you about a fairly trivial matter. I have been
> getting some inconsistencies with the display digits in R V1.5.  I have been
> using the hypergeometric distribution function, and have found that when
> printing out the results from this function the display does not seem to
> correspond to the number of digits requested in the options settings. Maybe
> this indicates that the vector hasn't been generated in the proper way, or
> something, but I thought I'd report it all the same.

Could you point out where it does not give the number of digits requested?
When you print out a vector R uses the same number of decimal places for
all entries, so one entry will have the number of significant digits
requested, but others may have more.

BTW, your example does not create temp, and you haven't told us the
platorm (as created by bug.report).

>
> [Previously saved workspace restored]
>
> > sqrt(2)
> [1] 1.414214
> > options(digits=4)
> > sqrt(2)
> [1] 1.414
> > options(digits=3)
> > for(j in 1:30){temp[j]<-sum(dhyper(0:6, j, 30 - j, 6)[3:7])}
> > temp
>  [1] 0.0000 0.0345 0.0936 0.1691 0.2543 0.3438 0.4333 0.5195 0.6002 0.6736
> [11] 0.7389 0.7956 0.8437 0.8835 0.9157 0.9410 0.9603 0.9744 0.9844 0.9912
> [21] 0.9954 0.9979 0.9992 0.9998 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
> > sqrt(2)
> [1] 1.41
> > temp
>  [1] 0.0000 0.0345 0.0936 0.1691 0.2543 0.3438 0.4333 0.5195 0.6002 0.6736
> [11] 0.7389 0.7956 0.8437 0.8835 0.9157 0.9410 0.9603 0.9744 0.9844 0.9912
> [21] 0.9954 0.9979 0.9992 0.9998 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
> > options(digits=4)
> > temp
>  [1] 0.00000 0.03448 0.09360 0.16913 0.25435 0.34383 0.43330 0.51954 0.60018
> [10] 0.67361 0.73889 0.79558 0.84368 0.88352 0.91571 0.94100 0.96026 0.97443
> [19] 0.98444 0.99116 0.99540 0.99788 0.99917 0.99976 0.99996 1.00000 1.00000
> [28] 1.00000 1.00000 1.00000
> > sqrt(2)
> [1] 1.414
> > x<-sqrt(2)
> > x
> [1] 1.414

-- 
Brian D. Ripley,                  ripley@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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


options(digits) (PR#1879)
ripley@stats.ox.ac.uk