[R] series at low freq expanded into high freq
Murali.MENON at fortisinvestments.com
Murali.MENON at fortisinvestments.com
Mon Apr 27 12:51:02 CEST 2009
Folks,
If I have a series mm of, say, monthly observations, and a series dd of
daily dates, what's a good way of expanding mm such that corresponding
to each day in dd within the corresponding month in mm, the values of mm
are repeated?
So e.g., if I have mm:
mm <- c(15, 10, 12, 13, 11)
names(mm)<-c("Nov 2008", "Dec 2008", "Jan 2009", "Feb 2009", "Mar
2009")
library(zoo)
mm <- zoo(mm, order.by = as.yearmon(names(mm), format="%b %Y"))
And days:
dd <- as.Date(c("03/11/2008", "05/11/2008",
"04/01/2009","02/02/2009","17/02/2009","13/03/2009","14/03/2009","18/03/
2009", "26/03/2009"), format="%d/%m/%Y")
I want to be able to create a series that looks like this:
03/11/2008 15
05/11/2008 15
04/01/2009 12
02/02/2009 13
17/02/2009 13
13/03/2009 11
14/03/2009 11
18/03/2009 11
26/03/2009 11
where because no daily dates in dd are in December, the final series has
no entries for December; there are two entries for November because
there are two dates in dd in November, etc.
Thanks,
Murali
More information about the R-help
mailing list