You can use seq.Date
to generate a sequence of monthly dates :
from <- as.Date("1974-01-01")
to <- as.Date("1989-12-31")
months <- seq.Date(from=from,to=to,by="month")
values <- rep.int(0,length(months))
Zooserie <- zoo(values, months)
# result:
> head(Zooserie)
1974-01-01 1974-02-01 1974-03-01 1974-04-01 1974-05-01 1974-06-01
0 0 0 0 0 0
> tail(Zooserie)
1989-07-01 1989-08-01 1989-09-01 1989-10-01 1989-11-01 1989-12-01
0 0 0 0 0 0
Note:
seq.Date
is the S3 method for generic function seq()
, so, since from
and to
are Date
object you can simply call seq()
and R automatically redirects on seq.Date
.