On Wed, 14 Jul 2010, Megh Dal wrote:
Hi all, can somebody help me to split a time series (zoo) object on monthwise.
For example, suppose I have following time series object:
library(zoo)
dat1 <- zooreg(rnorm(300), start=as.Date("2009-01-01"), frequency=1)
From dat1, I want to create a list-object dat2 like:
dat2[[1]] <- all observation for jan-2009
dat2[[2]] <- all observation for feb-2009
etc.
split(dat1, as.yearmon(time(dat1)))
seems to return what you want.
Z
Thanks
______________________________________________
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.
______________________________________________
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.