[Rd] stats::poly() stopped working for Date input -- intentional?

Michael Chirico ch|r|com @end|ng |rom goog|e@com
Fri Jul 8 07:17:12 CEST 2022


SVN#80126 added rep.difftime, which means rep(as.difftime(0,
units="secs")) retains the "datetime" class.

A consequence of this is that stats::poly() no longer accepts
Date/POSIXct input (because poly calls outer() on the de-meaned input,
which rep()):

# works on R 3.6.3 (and probably everything < 4.1.0)
#   but on R 4.1.3 (and probably everything >= 4.1.0):
stats::poly(Sys.Date() - 0:4, 3)
# Error in Ops.difftime(X, Y, ...) : '^' not defined for "difftime" objects

Is this intentional?

If not, a simple patch is to call 'x <- as.double(x)' before de-meaning.



More information about the R-devel mailing list