[R] Filtering a zoo object based on index of another object

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Mon Dec 7 13:39:04 CET 2009


On Mon, 7 Dec 2009, Subodh Acharya 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.

window(myzoo, DATE2)

See the vignettes for more details.
Best,
Z

> Any kind of help will be highly appreciated.
>
> Thanks in advance you very much
>
> -- 
> Acharya, Subodh
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
>




More information about the R-help mailing list