[R] Unexpected behaviour for as.date()

Isabella Ghement isabella at ghement.ca
Wed Nov 11 03:40:11 CET 2009


Hi everyone,

I am trying to use the function as.date() from the "dates" package in R
2.10.0 to convert a character date to a Julian date, as follows:

> as.date("02-MAY-01", order="mdy") # convert May 2, 2001 to a Julian date
[1] 2May1

However, when trying to convert a character date from the year 2000 to a
Julian date, I get an <NA> instead of the
desired Julian date:

> as.date("02-MAY-00", order="mdy") # convert May 2, 2000 to a Julian date
[1] <NA>

Not quite sure why R is unable to handle this type of date (perhaps it
thinks it comes from the year 1900?!).

Is there a way to force R to convert character dates from the year 2000 into
Julian dates?  I need to
perform this conversion in order to compute the difference between two
dates, one of which happens to come
from the year 2000.

Many thanks!

Isabella




More information about the R-help mailing list