0

would like to do multiple arima time series plot for each - Cooked and market - as shown in the image below. Have tried both autoplot and hchart but both does not work. Please advise and assist. Any help would be very much appreciated.

forecast1<-ts(lapply(arima, function(x) forecast(auto.arima(x), level=95)))

autoplot(forecast1)
hchart(forecast1)

Data:

s__
  • 9,270
  • 3
  • 27
  • 45
Joyce
  • 1
  • 2
  • 2
    Right now we can't tell exactly what your problem is or what you want your finished chart to look like - could you please edit your question to include [reproducible data](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), specify what you mean by "does not work" (error message? or plot doesn't look as expected?), and show us what you want the plot to look like. – Jan Boyer Nov 09 '18 at 16:29
  • Need a lot more info – jlbriggs Nov 11 '18 at 18:17

1 Answers1

1

I took the step of turning the data into a time series before using the forecast algorithm. Then printing the chart is just a matter of using apply on the new list that is generated. Please see the code below.

Year <- seq(2012, 2018)
Cooked <- c(157.4, 157.2, 168.8, 192.3, 201.8, 233.4, 241.2)
Market <- c(51.7, 44.9, 49.5, 53.6, 57.2, 54.1, 53.5)
df <- as.data.frame(cbind(Year, Cooked, Market))
ts_df <- ts(df[, -1], start = 2012, frequency = 1)

library(forecast)
forecast1<-lapply(ts_df, function(x) forecast(auto.arima(x), level=95))

lapply(forecast1, function(x) autoplot(x))

I recommend in future questions, putting the data together in a similar script to help us help you.

Richard Lusch
  • 1,050
  • 10
  • 19