I am trying to calculate and plot a forecast based on the moving average. Unfortunately, I can not manage to have the forecast displayed with an x axis representing the dates. I get a plot without dates based on my R Shiny code:
output$forecast<- renderPlot({
ts <- getSymbols(input$symb
, from = input$dates[1]
, to = input$dates[2]
, warnings = FALSE
, auto.assign = FALSE)
df <- data.frame(ts) #convert into data frame
names(df) <-c("Open", "High", "Low", "Close", "Volume", "Adjusted")
df$Date <- as.Date(rownames(df))
df$MA10 <- TTR::SMA (df$Close, n = 100)
ts <- df$MA10 %>% ts
fma <-forecast (ts, h=100)
main_label <- paste("100 days forecast based on moving average",
"\n",
names(which(codes == input$symb))," - ", input$symb,
"\n",
input$dates[1]," - ",input$dates[2]
)
plot(fma, xlab ="Days", ylab = "Closing prices", main = main_label)
})## End renderPlot
Is it possible to somehow include the dates into my graph? It currently looks like this: Forecast Plot RShiny