I am trying to return a time series that is of class "xts" "zoo". I would like to retrieve times but instead get numbers. I have an example below:
rtn<-c(rep(NA,3))
for(i in 1:3){
rtn[i]<-index(time_series[i])
}
This returns:
[1] 13704 14049 14343
This is what I would like it to return:
[1] "2007-07-10" "2008-06-19" "2009-04-09"
Thank you in advance for the help.
Above is a simplified version. It is the only part of the code that I can't get to run. If it is helpful here is the actual code:
green_rtn<-c(rep(NA,length(green_series_open[,1])))
for(i in 1:length(green_series_open[,1])){
green_rtn[i]<-straddles(coredata(green_series_open[i,1]),coredata(green_series_open[i,2]),
index(green_series_open[i]),index(green_series_close[i]))
}