Full_Name: Martin Becker Version: 2.4.1 OS: WinXP/Linux Submission from: (NULL) (134.96.96.42)
When using cut.Date() with 'breaks="year"', the month of the breakpoints is properly 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 asked on R-devel (2006-12-20), if there are reasons for this (in my opinion strange) behaviour, but since I got no answer, I suppose this behaviour is not intended and thus there is a bug in cut.Date(). The corresponding code fragment which defines the first breakpoint in the case 'breaks="year"' reads (2.4.1, 2.4.1 patched, 2.5.0): if (valid == 4) { start$mon <- 0 incr <- 366 } I think, the code fragment above should better read: if (valid == 4) { start$mon <- 0 start$mday <- 1 incr <- 366 } The following patch to src/library/base/R/dates.R should do this change: 301c301 < if(valid == 4) { start$mon <- 0; incr <- 366 } --- > if(valid == 4) { start$mon <- 0; start$mday <- 1; incr <- 366 } Kind regards, Martin ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel