0

I am working with shiny (shiny dashboard) and also doing a forecast of my dataset through the prophet package. Shiny is working perfect, and my forecast too. Now I would like to insert the code into shiny so to plot the forecast plot inside shiny. That's not working the output on the shiny app ist just white and not showing any output.

server code:

output$fcCrime <- renderPlot({

Year12_16 <- cc[cc$Year2 %in% c("2012", "2013", "2014", "2015", "2016"),]

df <- Year12_16 %>% group_by(Date2) %>% summarise(y = n()) %>% mutate(y = log(y))
names(df) <- c("ds", "y")
df$ds <- factor(df$ds)

m <- prophet(df)
future <- make_future_dataframe(m, 365*4)
forecast <- predict(m, future)
tail(forecast[c('ds', 'yhat', 'yhat_lower', 'yhat_upper')])
#plot(m, forecast, xlabel = "Year", ylabel = "Data")+ggtitle("Forecast of Crimes in Chicago")
dyplot.prophet(m, forecast)
#prophet_plot_components(m, forecast)

})

UPDATE: Working with this dataset: https://www.kaggle.com/currie32/crimes-in-chicago

Also updates the server code. The thing is without shiny everything is plotting and working fine, but inside the shiny app its not plotting anything on the shiny dashboard.

merv
  • 67,214
  • 13
  • 180
  • 245
S002
  • 31
  • 7
  • Could you please share a minimum reproducible code with some sample dataset to check your problem? – amrrs Jan 17 '19 at 06:22
  • @amrrs check my updates bro – S002 Jan 17 '19 at 06:58
  • 3
    it doesn't have the full code yet. the problem is you are using renderPlot which is for static plot while inside the function you are using dyplot which is for html plot (interactive). `dygraphOutput` and `renderDygraph` – amrrs Jan 17 '19 at 07:13
  • @amrrs thank you so much! That solved my problem :)) Today I have to finish my paper, but I have another problem with exporting leaflet map via shiny. I asked a week ago but nobody could help me. maybe you could help there again? thats the tread: https://stackoverflow.com/questions/54131837/export-download-leaflet-map-in-shiny-in-various-formats?noredirect=1#comment95101392_54131837 – S002 Jan 17 '19 at 13:05

0 Answers0