I'm new to Shiny and have been developing a web app that displays a plotly chart; I'm still developing the app on my local machine. When I run the app for the first time after opening RGui, the web app runs but does not render the chart, even after I have clicked the "Draw" button. I have to refresh the webpage once or twice and then the chart will render. Once the chart has rendered, the problem is gone for the duration of that R session. Refreshing the page or restarting the shiny program will continue to render the chart, until RGui is closed. The problem reliably recurs the next time I open RGui and run the app.
All the existing questions and answers I have searched on shiny and failed rendering have not answered my question.
After several frustrated attempts at trying to find what was wrong in my program, I boiled it down to this code that looks (to me) like it should be functional, but still presents the issue:
library(shiny)
library(plotly)
ui = fluidPage(
plotlyOutput("Plot"),
actionButton("drawPlotButton", "Draw")
)
server = function(input, output)
{
output$Plot = renderPlotly({
input$drawPlotButton
return(plot_ly(mtcars, x = ~hp, y = ~mpg, type = "scatter", mode = "markers"))
})
}
shinyApp(ui = ui, server = server)
I can't tell if I am missing something simple or what. All help is appreciated.