[R-SIG-Finance] Replacing zoo time series values

Research risk2009 at ath.forthnet.gr
Wed May 12 10:33:09 CEST 2010


Hello,

I am importing data, say S&P 500 from yahoo:

     SPyf<-yahooSeries("^GSPC", file="SPyahoo.csv", frequency="daily", 
nDaysBack=400)
     SPCOMPd<-(SPyf[,4])
     a<-time(SPCOMPd)
     SPd<-zoo(SPCOMPd,as.POSIXct(a))

I am not sure if the above is correct but I am trying to convert a 
timeSeries object to zoo.

 > is(SPCOMPd)
[1] "timeSeries" "structure"  "vector"
 >
 > is(SPd)
[1] "zoo"

I can do

SPCOMPd[1]<-SPCOMPd[2]+SPCOMPd[3]

with the timeseries object.

Is it possible to do something like:

SPd[1]<-(SPd[2]+SP[3])/2

with the zoo object?

I get:

Error in SPd[1] <- (SPd[2] + SP[3])/2 : replacement has length zero


Thanks in advance,
Costas



More information about the R-SIG-Finance mailing list