[R] Date Inconsistencies? Buglets?

ivo welch ivo.welch at gmail.com
Fri Aug 20 16:35:46 CEST 2010


The treatment of dates seems to be a little inconsistent in R 2.11.1
(2010-05-31):

[1] The choice of origins?

  > as.integer(as.Date("1970-01-01"))

works and assumes as origin 1970-01-01.  However,

  > as.Date(1)

does not work.  It requires an origin (as.Date(1,
origin="1970-01-01")).   If we set a default origin in the former, it
should probably work when the input is an integer rather than a
string, too.


[2] How do dates on axes work?

  > plot( c(as.Date(1:20, origin="1970-01-01")), 1:20 )
  > axis( side=3, c(as.Date(1:20, origin="1970-01-01")))

The lower axis is drawn from the plot() with dates.  The upper axis
from axis() is drawn with numbers, not dates.

(PS: Is there an easier way to tell R that I want a whole lot more
tick marks and/or labels than what it gives me by default?)


regards,

/iaw

----
Ivo Welch (ivo.welch at brown.edu, ivo.welch at gmail.com)



More information about the R-help mailing list