[Rd] cut.Date problem when starting on first day of week (PR#13159)

From: <bolker_at_zoology.ufl.edu>
Date: Mon, 13 Oct 2008 22:30:13 +0200 (CEST)

    Apparently any (?) call of the form


where the date *begins the week*, gives the error

Error in 1:(1 + max(which(breaks < maxx))) :   result would be too long a vector
In addition: Warning message:
In max(which(breaks < maxx)) :
  no non-missing arguments to max; returning -Inf

 To my surprise, this was first reported as a problem in 2006 (!) (version 2.3.1 (!)), by Mikkel Grum:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/83122.html (17 Aug 2006)

  In particular, try:

d <- seq.Date(as.Date("2008-07-05"),as.Date("2008-07-08"),by="days") weekdays(d)

cut(d[1],"weeks") ## OK
cut(d[2],"weeks") ## OK
cut(d[3],"weeks") ## Monday -- breaks
cut(d[4],"weeks") ## OK

cut(d[1],"weeks",start.on.monday=FALSE) ## OK
cut(d[2],"weeks",start.on.monday=FALSE) ## Sunday -- breaks
cut(d[3],"weeks",start.on.monday=FALSE) ## OK cut(d[4],"weeks",start.on.monday=FALSE) ## OK

  The particular line that fails within cut.Date is

breaks <- breaks[1:(1 + max(which(breaks < maxx)))]

  but I haven't figured out enough about what's going on to be able to suggest a fix ...

    Ben Bolker

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 13 Oct 2008 - 20:36:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 14 Oct 2008 - 05:30:19 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.

list of date sections of archive