[R] Date object and origin BC

smu ml at z107.de
Thu Dec 8 16:49:16 CET 2011


hi everybody,

is this intended behaviour?

> x <- as.Date('0-01-01')
> as.Date(as.character(x))
[1] "0-01-01"
> a <- x - 365
> as.Date(a)
[1] "-1-01-01"
> as.Date(as.character(a))
Error in charToDate(x) : 
character string is not in a standard unambiguous format

Is this a bug?

I found this, while trying to convert dates stored as 
"months since -2-01-01 00:00:00".
For the past I extracted this first_date string and converted my data
using 

dates <- as.Date(x, origin=as.Date(first_date))

But this fails with -2-01-01

Any ideas how to solve this? 

thanks and best regards,
 Stefan



More information about the R-help mailing list