Skip to content
Prev 109129 / 398500 Next

as.Date() behaviour when incomplete input string

Dear all,

I would like to know the month on a string formatted as "2004-01", using as.Date
(not just stripping the string !)

?as.Date says that in case of an incomplete input string, the answer is
system-specific.
The following has been tested on  R 2.4.1, on Ubuntu Linux and WinXP.
Error in fromchar(x) : character string is not in a standard unambiguous format.
(I understand that).
NA (is there still ambiguity in my format ??)

Investigating a bit, I found a strange behaviour in :
"2005-01-12"
NA (why can't R see anything ?)
"2005-02-09" (month and day are replaced by today's values, normal behaviour).

Why can't R see the month, but see the year ?

For the moment, I do this ugly thing :
as.Date.

Any idea how I can do better ?

Thanks and regards,

Nicolas Prune