Skip to content
Back to formatted view

Raw Message

Message-ID: <59EE907DC32.00000324bearmarketsrule@inbox.com>
Date: 2009-02-26T04:29:36Z
From: Rob Denniker
Subject: Importing zoo object ("index contains NAs")

Dear list,

I have an irregular time series saved and exported as a zoo object. What is the trick to force zoo to ignore the missing dates when reading it back in? Thanks.

> str(g)
?zoo? series from 1948-11-02 to 2012-11-06
  Data: num [1:14881, 1:8] 1 0 0 0 0 0 0 0 0 0 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:8] "session" "midterm" "day.of.wk" "elapsed" ...
  Index: Class 'Date'  num [1:14881] -7730 -7303 -7302 -7301 -7300 ...

> write.zoo(g, file = "gdata.txt", index.name = "date", append = F, quote = T, sep = ",")

> h <- read.zoo("gdata.txt", sep = ",", format = "Y-%m-%d")
Error in read.zoo("gdata.txt", sep = ",", format = "Y-%m-%d") : 
  index contains NAs