[R] Generating date variables
Paul Gilbert
pgilbert at bank-banque-canada.ca
Thu Nov 15 18:38:47 CET 2001
Mark Scarr wrote:
> I would like to generate a vector of dates
> to plot on a graph (i.e a string vector)
> for example 05/04/2001 would be 4th May 2001
You can do this with
a <- seq(ISOdate(2001,1,1,tz="GMT"), ISOdate(2001,12,31,tz="GMT"),"days")
format(a, format="%m/%d/%Y", tz="GMT")
If you live in GMT then I think you can omit the tz. There may be an easier way
if you don't live in GMT, but I can't find it. The problem is getting ISOdate to
generate a time at midnight, so that format will automatically drop the time
from the date.
Paul Gilbert
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list