[Rd] as.Date.numeric

Gabor Grothendieck ggrothendieck at myway.com
Mon Mar 22 23:43:11 CET 2004



In rereading my post, he as.Date(x)+as.Date(y) part of 
the equivalence should be removed.  The rest of it
is ok.


Date:   Mon, 22 Mar 2004 17:35:27 -0500 (EST) 
From:   Gabor Grothendieck <ggrothendieck at myway.com>
To:   <R-devel at stat.math.ethz.ch> 
Subject:   [Rd] as.Date.numeric 

 


Regarding the new R 1.9.0 Date class, it would be nice to have
as.Date.numeric . 

1. as.numeric(x) works for Date objects and it would be convenient 
to also have the inverse. 

2. It leads to some nice additive properties for integer x and y:
as.Date(x+y) = as.Date(x) + as.Date(y) 
= as.Date(x) + y = as.Date(y) + x

3. It gives a pleasing way to quickly get the origin:
as.Date(0)

4. The corresponding ability is already available in chron,
e.g. chron(0), and I have found that I did make use of it
in my work with chron.

5. Its particularly convenient in testing since you can quickly
generate a sequence of dates like this:
as.Date(1:100)

Its quite simple to implement:

as.Date.numeric <- function(x) structure( floor(x), class = "Date" )



More information about the R-devel mailing list