[R] converting a zoo or an xts to a data frame
Erin Hodgess
erinm.hodgess at gmail.com
Tue Apr 20 04:31:52 CEST 2010
Dear R People:
I have the following code that I use to convert a monthly zoo object
to a data.frame, and it works perfectly:
library(tseries)
z <- get.hist.quote(instrument=inst1, start=start1,end=end1,
quote=quot1,comp = "m")
y <- as.ts(aggregate(z, as.yearmon, tail, 1))
y.df <- data.frame(y=y,time=time(y))
y.df$x <- ts(y.df[,1])
tsp(y.df$x) <- tsp(y.df[,2])
names(y.df) <- c("data","time","ts")
z.df <- data.frame(ts=y.df$ts)
Fair enough. Now I would like to take a daily or weekly zoo and
convert that to a data frame. It will probably follow a similar
pattern to what I have here, but I'm not sure how to do this.
Any help would be much appreciated.
thanks,
Erin
--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com
More information about the R-help
mailing list