[Rd] Possible bug in cut.Date()

From: Martin Becker <martin.becker_at_mx.uni-saarland.de>
Date: Wed 20 Dec 2006 - 18:00:00 GMT

Dear list,

I suppose that the behaviour of cut.Date() is not as intended for the case ' breaks="year" ' (in R 2.4.1 and previous versions): The corresponding code fragment which defines the first breakpoint in this case reads:

        if (valid == 4) {
            start$mon <- 0
            incr <- 366

So the month of the first breakpoint is set to January, but the day of month is not set to 1.
This leads to a strange behaviour, see the following example:

> cut(as.Date(c("2000-01-17","2001-01-13","2001-01-20")),breaks="y")
[1] 2000-01-17 2000-01-17 2001-01-17
Levels: 2000-01-17 2001-01-17

I think, the code fragment above should better read:

        if (valid == 4) {
            start$mon <- 0
            start$mday <- 1
            incr <- 366

(Of course, maybe there are reasons for the current behaviour which I am not aware of, and the current behaviour is as intended.)



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Dec 21 16:07:48 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 21 Dec 2006 - 08:31:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.