I am trying to create a vector with the sum of the forecasts created but the vector is only storing the last value, how to create a vector with each sum?
library(forecast)
setwd("C:\\Users\\Note\\Documents\\Ssl")
n <- dir(pattern = ".csv")
forecastOut <- lapply(n, function(x) {
dat <- read.csv(x, sep=";", header = TRUE)
predic <- auto.arima(dat[,1])
forecast(predic, h = 4)
})
names(forecastOut) <- n
for (i in forecastOut){
sum<-c(sum(unlist((i[4]))))
}
>sum
[1] 2944.32
> class(forecastOut)
[1] "list"