[R] Bug? in summary( ) function base package

Richard Saba sabaric at auburn.edu
Wed Apr 30 20:06:17 CEST 2008


There seems to be an error in the summary() function when applied to "ts"
class objects. The results of a call to summary( ), on the R  "ts" data set
USAccDeaths , reports the wrong value for Max. The value reported by the
summary function is 11320. The max( ) function returns the correct value
11317, the July 1993 value. Coercing the data to a data.frame and calling
summary returns the correct max value. A search of R -help found a post in
2007 that mentioned a problem but attributed it to rounding errors. But this
is too large a difference to account for a simple rounding error. 

Has anyone else encountered the problem? Is there a workaround?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

R version 2.6.2 Patched (2008-02-08 r44394)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> data(USAccDeaths)
> summary(USAccDeaths)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   6892    8089    8728    8789    9323   11320 
> max(USAccDeaths)
[1] 11317
> USAccDeaths
       Jan   Feb   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec
1973  9007  8106  8928  9137 10017 10826 11317 10744  9713  9938  9161  8927
1974  7750  6981  8038  8422  8714  9512 10120  9823  8743  9129  8710  8680
1975  8162  7306  8124  7870  9387  9556 10093  9620  8285  8466  8160  8034
1976  7717  7461  7767  7925  8623  8945 10078  9179  8037  8488  7874  8647
1977  7792  6957  7726  8106  8890  9299 10625  9302  8314  8850  8265  8796
1978  7836  6892  7791  8192  9115  9434 10484  9827  9110  9070  8633  9240

> dat1<-as.data.frame(USAccDeaths)
> summary(dat1)
       x        
 Min.   : 6892  
 1st Qu.: 8089  
 Median : 8728  
 Mean   : 8789  
 3rd Qu.: 9323  
 Max.   :11317  
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Thanks,
R Saba



More information about the R-help mailing list