From simon.urbanek at r-project.org  Fri Mar  2 16:25:10 2012
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Fri, 2 Mar 2012 10:25:10 -0500
Subject: [Rd] print method for summary adds trailing zero
In-Reply-To: <5D46A8E0D922A14E98DA61151D68DF870140247139E6@DJFEXMBX01.djf.agrsci.dk>
References: <5D46A8E0D922A14E98DA61151D68DF870140247139E6@DJFEXMBX01.djf.agrsci.dk>
Message-ID: <2A8316E9-079D-4E42-9A57-E17D733F96A7@r-project.org>


On Mar 2, 2012, at 8:57 AM, Ole Fredslund Christensen wrote:

> Dear R-devel
> 
> Thought I better report this. An example is shown below.
> 
>> vec <- rnorm(100)+10.5
>> ss <- summary(vec)
>> print(ss)
>   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
>  8.433   9.886  10.450  10.560  11.300  12.720
>> for(kk in 1:length(ss)) print(ss[[kk]])
> [1] 8.433
> [1] 9.886
> [1] 10.45
> [1] 10.56
> [1] 11.3
> [1] 12.72
>> print(mean(vec))
> [1] 10.56399
> 
> Note the difference between 10.56399 and 10.560.
> It may confuse users that the number of significant digits is smaller than the number of digits shown by the print of a summary object (at least it confused me).
> 

Well, that's not even the really confusing one -- thy this:

> vec <- round((rnorm(100)+10.5)*100000)
> summary(vec)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 768000  966000 1053000 1048000 1107000 1316000 
> max(vec)
[1] 1315985

That's the point at which you decide never to use summary() again ;).

Cheers,
Simon



[Rd] print method for summary adds trailing zero
Simon Urbanek