Omit rep. ?You just want ?a <- zoo(1:9, ...). To get the last day of
the month you don`t need b since as.Date.yearmon will give it with the
argument frac = 1:
aggregate(a, as.Date(as.yearmon(time(a)), frac = 1), tail, 1)
2009-03-31 2009-04-30 2009-05-31 2009-06-30
? ? ? ? 2 ? ? ? ? ?5 ? ? ? ? ?8 ? ? ? ? ?9
On Thu, Apr 8, 2010 at 11:18 AM, Sergey Goriatchev <sergeyg at gmail.com> wrote:
Hello, everyone
I have the following problem:
Say I have an irregular zoo timeseries like this:
a <- zoo(rep(1:9), as.Date(c("2009-03-20", "2009-03-27", "2009-04-24",
"2009-04-25", "2009-04-30", "2009-05-15", "2009-05-22", "2009-05-29",
"2009-06-26")))
and I have regular zoo timeseries like this:
b <- zoo(rep(1:4), as.Date(c("2009-03-31", "2009-04-30", "2009-05-31",
"2009-06-30")))
From "a" I need to extract those rows that hold values for the last
day of each month (creating series "c"). Then I have to merge these
values with "b", such that the result has the index of "c".
How could I do this most efficiently?
Thank you in advance!
Best,
Sergey
--
Simplicity is the last step of art./Bruce Lee