summary() rounding

8.7k views Asked by At

Can someone explain why R does this? Rounding max and mins on integer values seems extremely flawed.

summary(1:1283932)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
      1  321000  642000  642000  962900 1284000 
max(1:1283932)
[1] 1283932
2

There are 2 answers

0
jrdnmdhl On BEST ANSWER

This works if you set your display precision to enough digits:

options(digits=10)
summary(1:1283932)
 Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
  1.0  320983.8  641966.5  641966.5  962949.2 1283932.0
1
Alexey Ferapontov On

Default display precision is 4 digits. Use digits explicitly, e.g.:

> summary(1:1283932,digits=7)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
      1  320984  641966  641966  962949 1283932