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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue, 14 Oct 2008 04:54:45 +0100 (BST)

It should be <= not < .

There is a similar problem with POSIXct (but only for times at midnight).

On Mon, 13 Oct 2008, bolker_at_zoology.ufl.edu wrote:

> Apparently any (?) call of the form
>
> cut(date,"weeks")
>
> 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)
> https://stat.ethz.ch/pipermail/r-devel/2008-September/050710.html
> https://stat.ethz.ch/pipermail/r-devel/2008-October/050914.html
>
> 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 ...
>
> cheers
> Ben Bolker
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 14 Oct 2008 - 03:59:05 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 - 06: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