Since DATE2 is a subset of time(myzoo) either of these should work window(myzoo, DATE2)
myzoo[DATE2] If DATE2 were not a subset of time(myzoo) then you could do this: myzoo2 <- na.locf(merge(myzoo, zoo(, DATE2))) and now use either of the first two expressions with myzoo2 in place of myzoo. On Mon, Dec 7, 2009 at 7:22 AM, Subodh Acharya <shoeb...@gmail.com> wrote: > Hello everybody, > I have two datasets, observed and predicted. > Since my observed dataset is not in regular intervals, I need to filter my > predicted dataset based on the measurement date of my observed data. > Here, is an example similar to what I have > > library(chron);library(zoo) > DATE<- seq(as.Date("2009-01-01"), as.Date("2009-05-01"), by = 1) > mydat<- rnorm(length(DATE), 20,5) > myzoo<- zoo(mydat, order.by = DATE) > DATE2<- seq(as.Date("2009-01-01"), as.Date("2009-01-30"), by = 7) > > Now I need to create a new zoo object with index as DATE2 and corresponding > data values. > > Any kind of help will be highly appreciated. > > Thanks in advance you very much > > -- > Acharya, Subodh > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.