Re: [R] summary() doesn't work with Date class objects

2004-07-14 Thread Uwe Ligges
Scott Waichler wrote:
The handy function summary() doesn't work correctly with Date class
objects:

R.version.string
[1] R version 1.9.1, 2004-06-21
b - as.Date(c(2002-12-26, 2002-12-27, 2002-12-28, 2002-12-29, 2002-12-30))
b
[1] 2002-12-26 2002-12-27 2002-12-28 2002-12-29 2002-12-30
summary(b)
Min.  1st Qu.   Median Mean  3rd Qu. Max.
2002-12-29 2002-12-29 2002-12-29 2002-12-29 2002-12-29 2002-12-29
The obvious fix is to change summary.date (in 
.../src/library/base/R/dates.R) as follows:

old:
summary.Date - function(object, ...)
{
x - summary.default(unclass(object), ...)[1:6]# not NA's
class(x) - oldClass(object)
x
}
new:
summary.Date - function(object, ...)
{
x - unclass(object)
x - summary.default(x, digits = floor(log(x)) + 1, ...)[1:6]# not NA's
class(x) - oldClass(object)
x
}

One might want to change floor(log(x)) + 1 to something less 
computational in intensive like 10. ;-)

Uwe Ligges
BTW: Should I submit a bug report or does anybody fix the sources at once?

Scott Waichler
Pacific Northwest National Laboratory
Richland, WA   99352USA
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] summary() doesn't work with Date class objects

2004-07-13 Thread Scott Waichler

The handy function summary() doesn't work correctly with Date class
objects:

 R.version.string
[1] R version 1.9.1, 2004-06-21
 b - as.Date(c(2002-12-26, 2002-12-27, 2002-12-28, 2002-12-29, 2002-12-30))
 b
[1] 2002-12-26 2002-12-27 2002-12-28 2002-12-29 2002-12-30
 summary(b)
Min.  1st Qu.   Median Mean  3rd Qu. Max.
2002-12-29 2002-12-29 2002-12-29 2002-12-29 2002-12-29 2002-12-29

Scott Waichler
Pacific Northwest National Laboratory
Richland, WA   99352USA
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html