Skip to content
Prev 138923 / 398506 Next

Irregular Time Series Issue

I noticed a problem with the merging factors so try
using character variables instead:

library(zoo)
Lines <- "Time Data Time1 Data1
1       b        1         e
7      g         4        i
NA  NA       5         k
NA  NA      NA      NA
"
DF <- read.table(textConnection(Lines), header = TRUE, as.is = TRUE)
f <- function(i) { DF <- na.omit(DF[i + 0:1]); zoo(DF[,2], DF[,1]) }
ix <- seq(1, ncol(DF), 2)
ser <- lapply(ix, f)
names(ser) <- names(DF)[-ix]

# optional
do.call(merge, ser)


On Fri, Mar 7, 2008 at 8:35 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote: