Skip to content
Prev 165115 / 398513 Next

For and if confusion

Make a series of ones from each start/end pair and merge them all
with A using fill = 0.  We have returned a ts series since that seems
to be what you are using but we could have left off the as.ts to
return a zoo series in the end:

library(zoo)

X <- as.Date(c("01-03-1993", "01-05-1997"), "%d-%m-%Y")
Xs <- zoo(1, as.yearmon(seq(X[1], X[2], "month")))

Y <- as.Date(c("01-02-1995", "01-08-1999"), "%d-%m-%Y")
Ys <- zoo(1, as.yearmon(seq(Y[1], Y[2], "month")))

A <- ts(rnorm(120), freq=12, start=c(1992,8))
as.ts(with(merge.zoo(Xs, Ys, A, fill = 0), pmax(Xs, Ys)))



On Thu, Dec 18, 2008 at 5:12 AM, Shruthi Jayaram
<shruthi.jayaram.85 at gmail.com> wrote: