I created a data set like this, the reason is I wanted to use a time series based data set 

```
getSymbols("^GSPC")
DF=data.frame(GSPC,DATE=time(GSPC))
PriceChange=(DF$GSPC.Close-DF$GSPC.Open)
DF$Class<-as.factor(ifelse(PriceChange>0,"UP","DOWN")) 
DF$year = as.numeric(format(DF$DATE, format = "%Y"))
DF$MONTH = as.numeric(format(DF$DATE, format = "%m"))

GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume Class Year Month
1418.03   1429.42  1407.86    1416.60  3429160000   Down  2007   1
1416.60   1421.84  1408.43    1418.34  3004460000   Up    2007   1

```

Then I replaced the year by a number which can be added on to keep the month index (I guess there is a smarter way of doing this)

```
DF=data.table(DF)

DF[year==2007,year:=0]
DF[year==2008,year:=12]
DF[year==2009,year:=24]
DF[year==2010,year:=36]
DF[year==2011,year:=48]
DF[year==2012,year:=60]
DF[year==2013,year:=72]
DF[year==2014,year:=84]
DF[year==2015,year:=96]
DF[year==2016,year:=108]

DF$Month_Index=(DF$year+DF$MONTH)

```

so the data set has now the additional column 

```
Month_Index
 01
 01

Month_Index=115

```

Then I used the `createTimeSlices` from `caret` to make a growing window prediction. 

```
TimeSlices=createTimeSlices(1:Month_Index, 5, horizon = 2,
             fixedWindow = FALSE, skip = 0)

for(i in 1:nrow(DF))
{

  plsFitTime <- train(Class~.,
                      data = DF[TimeSlices$train[[i]],],
                      method = "pls")

  Prediction=predict(plsFitTime,DF[TimeSlices$test[[i]],])

}

```

Now I want to save predictions for each step and its proper index along with the accuracy. My question is how can I do this.