[Rd] (PR#13159) cut.Date problem when starting on first day of week
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Oct 14 05:54:45 CEST 2008
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
More information about the R-devel
mailing list