[Rd] summary.default rounding on numeric seems inconsistent with other R behaviors

John Mount jmount at win-vector.com
Fri Aug 19 17:04:55 CEST 2016

I was wondering if it would make sense to change the default behavior of the following:

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   15560   15560   15560   15560   15560   15560 

summary.default on numeric values rounds values (not just presentation) to getOption("digits")-3L (or four) digits by default, making those values surprising and less suitable for further calculation.  Summary on matrix and data.frame do not do so.

It seems it would be nice to have x=15555L; summary(x)[['Min.']] == min(x) evaluate to TRUE.  I know one can alter behavior by changing the global “digits” option, but I don’t know what other impacts that might have.  Ideally I would think summary.default would not round its values at all, but use digits to control presentation (by overriding print and such).  Even in presentation the rounding without switching to scientific notation (such as 1.556e+4) is a bit surprising (I understand rounding and scientific notation are two different presentation issues, but new users are very confused that something that appears to be an integer has been rounded).


##        x        
##  Min.   :15555  
##  1st Qu.:15555  
##  Median :15555  
##  Mean   :15555  
##  3rd Qu.:15555  
##  Max.   :15555  
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   15560   15560   15560   15560   15560   15560 

I have a (bit whiny) polemic trying to explain the pain point here http://www.win-vector.com/blog/2016/08/my-criticism-of-r-numeric-summary/ <http://www.win-vector.com/blog/2016/08/my-criticism-of-r-numeric-summary/> (I am not trying to be rude, more I am trying to emphasize why this can be confusing to new users).

John Mount
http://www.win-vector.com/ <http://www.win-vector.com/> 
Our book: Practical Data Science with R http://www.manning.com/zumel/ <http://www.manning.com/zumel/>

	[[alternative HTML version deleted]]

More information about the R-devel mailing list