Ole Fredslund Christensen
2012-Mar-02 13:57 UTC
[Rd] print method for summary adds trailing zero
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). Yours Ole F. Christensen [[alternative HTML version deleted]]
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