I've hit a problem in ggplot2 which I can trace back to cut.Date , which is either a bug or (??) ggplot2 trying to do something it shouldn't with cut.Date (although its use of cut.Date seems OK).
Apparently any (?) call of the form cut(as.Date("2008-07-07"),"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 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 session info: > sessionInfo() R version 2.7.2 (2008-08-25) i486-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] splines grid stats graphics grDevices utils datasets [8] methods base other attached packages: [1] ggplot2_0.7 MASS_7.2-44 RColorBrewer_1.0-2 proto_0.3-8 [5] reshape_0.8.1 plyr_0.1 Here's the context in which I encountered the problem: library(ggplot2) tdat <- data.frame(date=seq.Date(as.Date("2008-07-07"), as.Date("2008-10-10"),by="day"), x=1:96) q2 = qplot(date,x,data=tdat,geom="smooth") print(q2+geom_point()) I can track the problem down to a call like floor_date(as.Date("2008-07-07"),"weeks") and digging further in, I can narrow it down to the issue above. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel