Reputation: 2508
I am foresting with ets function from the forecast package.I have daily data from sales for each days in the period from 2015-01-01 until 2015-12-01.Output from this coding is forecast object.This forecast object don't have properly date so I must put forecast into table.
library(forecast)
library(lubridate)
forecast_horizont<-10
DATA_TEST<-data.frame(date_of_sale = seq.Date(as.Date("2015-01-01"), as.Date("2015-12-01"), by = "day"),
value=sample(1:50, 335, replace=TRUE))
For the purpose of forecasting, next step should be how to make table like table below.
In below code line I must put forecast_horizont and for that reason I try with this line of code.But there is problem and this line does not work.
EXPAND_DATA_set<-data.frame(date_of_sale = seq.Date(as.Date("2015-12-01"), by = "day")+forecast_horizont)
So can anybody help me how to fix this line of code and make table like table on above pic with using forecast_horizont ?
Upvotes: 0
Views: 44
Reputation: 388817
Are you trying to add forecast_horizont
days starting from "2015-12-01"
?
data.frame(date_of_sale = seq(as.Date("2015-12-01"), by = "day", length.out = forecast_horizont))
# date_of_sale
#1 2015-12-01
#2 2015-12-02
#3 2015-12-03
#4 2015-12-04
#5 2015-12-05
#6 2015-12-06
#7 2015-12-07
#8 2015-12-08
#9 2015-12-09
#10 2015-12-10
OR
data.frame(date_of_sale = as.Date('2015-12-01') + 0:forecast_horizont)
Upvotes: 1