[Rd] Rounding in print.summaryDefault()

Dirk Eddelbuettel edd at debian.org
Sun May 28 17:51:22 CEST 2017


On 28 May 2017 at 17:37, Arne Henningsen wrote:
| Dear all
| 
| I am happy that summary.default() no longer rounds since R 3.4.0.
| 
| However, in R 3.4.0, in a few cases, print.summaryDefault() rounds the
| mean value (and the median value) differently on my GNU/Linux machine
| and on my colleague's MS-Windows machine. Here is a small (simplified)
| reproducible example:
| 
| R> a <- 1234568.01 + c(0:1)
| R> summary(a)
| 
| Output on MS-Windows (expected rounding of the mean value):
|    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
| 1234568 1234568 1234569 1234569 1234569 1234569
| 
| Output on GNU/Linux (unexpected rounding of the mean value):
|    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
| 1234568 1234568 1234568 1234568 1234569 1234569

Not here:

R> a <- 1234568.01 + c(0:1)
R> a
[1] 1234568 1234569
R> summary(a)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
1234568 1234568 1234569 1234569 1234569 1234569 
R> Sys.info()
                                      sysname 
                                      "Linux" 
                                      release 
                           "4.8.0-39-generic" 
                                      version 
"#42-Ubuntu SMP Mon Feb 20 11:47:27 UTC 2017" 
                                     nodename 
                                        "max" 
                                      machine 
                                     "x86_64" 
                                        login 
                                        "edd" 
                                         user 
                                        "edd" 
                               effective_user 
                                        "edd" 
R> 

Ubuntu 16.10, 64bit.

Dirk
 
| The following code gives the same output on MS-Windows and on GNU/Linux:
| R> print(summary(a), digits=9)
|     Min.   1st Qu.    Median      Mean   3rd Qu.      Max.
| 1234568.0 1234568.3 1234568.5 1234568.5 1234568.8 1234569.0
| R> summary(a)["Mean"]
|   Mean
| 1234569
| R> mean(a)
| [1] 1234569
| R> print(mean(a), digits=9)
| [1] 1234568.51
| 
| Can these outputs be reproduced by other GNU/Linux and MS-Windows users?
| 
| If these differences can be reproduced by others: Should these
| differences in the output on GNU/Linux and MS-Windows be considered as
| a bug?
| 
| Does anybody know how one can avoid to get different roundings in the
| outputs of summary() on different computers?
| 
| Best,
| Arne
| 
| -- 
| Arne Henningsen
| http://www.arne-henningsen.name
| 
| ______________________________________________
| R-devel at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-devel mailing list