From Kurt@Horn|k @end|ng |rom wu@@c@@t  Wed Sep  8 08:18:42 2021
From: Kurt@Horn|k @end|ng |rom wu@@c@@t (Kurt Hornik)
Date: Wed, 8 Sep 2021 08:18:42 +0200
Subject: [Rd] Should seq.Date() return double storage?
In-Reply-To: <CAD7Bkx8G-74PxQpchi2+ejTEKzOVaPih2o13pmbhmRRo9FTCLg@mail.gmail.com>
References: <CAD7Bkx8G-74PxQpchi2+ejTEKzOVaPih2o13pmbhmRRo9FTCLg@mail.gmail.com>
Message-ID: <24888.21954.735124.993759@hornik.net>

>>>>> 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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



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