On Thu, 23 Aug 2007 [EMAIL PROTECTED] wrote:

> i'm trying to convert a zoo object of the following specifications:
>
> > str(z)
>  atomic [1:15642] 0 0 0 0 0 0 0 0 0 0 ...
>  - attr(*, "index")='POSIXct', format: chr [1:15642] "2004-09-01 02:00:00" 
> "2004-09-01 03:00:00" "2004-09-01 04:00:00" "2004-09-01 05:00:00" ...
>  - attr(*, "frequency")= num 0.000278

(Side note 1: The frequency looks suspicious...you probably want a "zoo"
rather than a "zooreg" object.)

> to convert into a dataframe. the atomic object (or what it is...) is

(Side note 2: a vector for univariate zoo series, a matrix for
multivariate zoo series.)

> convertet correctly, but the time attribute in the POSIXct format is
> replaced by an index number
>
> how can i get my data with the corresponding date/time as a second column?

Just add it afterwards, e.g.,
  z <- zoo(cbind(a = 1:5, b = 2:6), as.POSIXct(as.Date("2007-01-01") + 0:4))
  d <- as.data.frame(z)
  d$Date <- time(z)

(Side note 3: The reason for not including the date is that we wanted the
data to be as similar as possible in the zoo series and the data frame,
e.g., for
  lm(a ~ ., data = as.data.frame(z))
)

hth,
Z

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to