[R] Significant integer digits in summary.default

D G Rossiter rossiter at itc.nl
Thu Sep 21 10:17:30 CEST 2006


On R 2.3.1 I was surprised to see the following results from  
summary.default():

R> x <- scan()
1: 12148 10426 10912  9116 13226 11663 11781 10680  8457 10788 12605  
10591 11040
14: 10815 12962 11644 10047 10478 10108 12353 11778 11092 11673  8758  
11145 11495
27:
Read 26 items
R> summary(x)
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
    8460   10500   11100   11100   11800   13200
R> max(x)
[1] 13226

Clearly, these are being rounded; help(summary) shows the digits=  
option. If I now ask for all five digits (n.b. I have to know the  
magnitude of the numbers to know how many integer digits) I get:

R> summary(x, digits=5)
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
    8457   10506   11066   11068   11752   13226

which now shows the actual maximum etc.

help(summary) shows options:  digits = max(3, getOption("digits")-3)
R> getOption("digits")
[1] 5

So in my case I get three digits... but I had thought this applied to  
decimal digits, not integer digits, and that rounding would only  
occur in decimal places, according to the digits option.

Question: is this behaviour of summary.default what is expected? If  
so, it seems non-intuitive to me.

Thank you,

D. G. Rossiter
Senior University Lecturer
Department of Earth Systems Analysis
International Institute for Geo-Information Science and Earth  
Observation (ITC)
Enschede, The Netherlands



More information about the R-help mailing list