Skip to content
Prev 1879 / 15274 Next

disaggregating weekly to daily series

The zoo package can do that in one line but first read the weekly data
into a zoo object, w, and the dates into a one-column data frame d.

library(zoo)

Lines <- "1999-02-19    128.72
1999-02-26    129.15
1999-03-05    131.76
"
w <- read.zoo(textConnection(Lines))

Lines <- "1999-02-15
1999-02-16
1999-02-17
1999-02-18
1999-02-19
1999-02-22
1999-02-23
1999-02-24
"
d <- read.table(textConnection(Lines), colClasses = "Date")


# Now create a 0-width zoo object from the dates, d, and merge it with the
# weekly zoo object.  Then use na.locf to fill in NAs with Last Observation
# Carried Forward.

na.locf(merge(w, zoo(, d[[1]])))
On Nov 13, 2007 10:22 PM, Ian Seow <ianseow at gmail.com> wrote: