Date sequence in R spanning B.C.E. to A.D

date, r

Solution

To expand on Ricardo's suggestion, here is some testing of how things work. Or don't work for that matter.

I will repeat Joshua's warning taken from `?as.Date` for future searchers in big bold letters:

"Note: Years before 1CE (aka 1AD) will probably not be handled correctly."

as.integer(as.Date("0/1/1"))
[1] -719528

as.integer(seq(as.Date("0/1/1"),length=2,by="-10000 years"))
[1]  -719528 -4371953

seq(as.Date(-4371953,origin="1970-01-01"),Sys.Date(),by="1000 years")
# nonsense
 [1] "0000-01-01" "'000-01-01" "(000-01-01" ")000-01-01" "*000-01-01"
 [6] "+000-01-01" ",000-01-01" "-000-01-01" ".000-01-01" "/000-01-01"
[11] "0000-01-01" "1000-01-01" "2000-01-01"

> as.integer(seq(as.Date(-4371953,origin="1970-01-01"),Sys.Date(),by="1000 years"))
# also possibly nonsense
 [1] -4371953 -4006710 -3641468 -3276225 -2910983 -2545740 -2180498 -1815255
 [9] -1450013 -1084770  -719528  -354285    10957

Though this does seem to work for graphing somewhat:

yrs1000 <- seq(as.Date(-4371953,origin="1970-01-01"),Sys.Date(),by="1000 years")
plot(yrs1000,rep(1,length(yrs1000)),axes=FALSE,ann=FALSE)
box()
axis(2)
axis(1,at=yrs1000,labels=c(paste(seq(10000,1000,by=-1000),"BC",sep=""),"0AD","1000AD","2000AD"))
title(xlab="Year",ylab="Value")

Problem

I would like to generate a sequence of dates from 10,000 B.C.E. to the present. This is easy for 0 C.E. (or A.D.): ``` ADtoNow <- seq.Date(from = as.Date("0/1/1"), to = Sys.Date(), by = "day") ``` But I am stumped as to how to generate dates before 0 AD. Obviously, I could do years before present but it would be nice to be able to graph something as BCE and AD.

Original source