From ggrothendieck at myway.com  Mon Mar 22 23:35:27 2004
From: ggrothendieck at myway.com (Gabor Grothendieck)
Date: Mon Mar 22 23:35:34 2004
Subject: [Rd] as.Date.numeric
Message-ID: <20040322223527.0E6F13992@mprdmxin.myway.com>



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" )


[Rd] as.Date.numeric
Gabor Grothendieck