[R-SIG-Finance] Replacing zoo time series values
ggrothendieck at gmail.com
Wed May 12 12:49:47 CEST 2010
SPyf<-yahooSeries("^GSPC", file="SPyahoo.csv", frequency="daily", nDaysBack=400)
z <- as.zoo(SPyf)
z[,1] <- (z[,2]+z[,3])/2
colnames(z) <- "hilo"
See the three vignettes that come with zoo for many examples. In
particular, vignette("zoo-quickref") illustrates the use of the
tseries package to read a series from yahoo directly into a zoo
object. Also see the related quantmod and xts packages.
On Wed, May 12, 2010 at 4:33 AM, Research <risk2009 at ath.forthnet.gr> wrote:
> I am importing data, say S&P 500 from yahoo:
> SPyf<-yahooSeries("^GSPC", file="SPyahoo.csv", frequency="daily",
> I am not sure if the above is correct but I am trying to convert a
> timeSeries object to zoo.
>  "timeSeries" "structure" "vector"
>  "zoo"
> I can do
> with the timeseries object.
> Is it possible to do something like:
> with the zoo object?
> I get:
> Error in SPd <- (SPd + SP)/2 : replacement has length zero
> Thanks in advance,
> R-SIG-Finance at stat.math.ethz.ch mailing list
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
More information about the R-SIG-Finance