[Rd] Should seq.Date() return double storage?

Kurt Hornik Kurt@Horn|k @end|ng |rom wu@@c@@t
Wed Sep 8 08:18:42 CEST 2021


>>>>> Michael Chirico via R-devel writes:

> today <- Sys.Date()
> typeof(today)
> # [1] "double"
> typeof(seq(today, by=1, length.out=2))
> # [1] "integer"

> Clearly minor as it doesn't seem to have come up before (e.g. coercion
> to numeric will happen automatically whenever fractional dates are
> needed); I only noticed because of a test using identical failing:

> identical(
>   seq(today, by=1, length.out=10),
>   today + 0:9
> )
> # [1] FALSE

> It's easy in this case to fix the test using coercion, but this could
> (and did in practice) come up at deeper levels of nesting that become
> more onerous to handle. And using all.equal() comes with its own
> tradeoffs.

> The fix would be easy enough -- at a glance there are two usages of
> .Date(seq.int(...)) in seq.Date() that could be replaced by
> .Date(as.numeric(seq.int(...))).

Thanks.  Can you pls provide a patch for these?

Best
-k

> Mike C

> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list