Choose a RData dataset before launching rest of Shiny app

Hi All-

I apologize if this is a basic question. I have searched, but I may just not know how to ask it properly. I have designed a fairly complex shinydashboard which begins by loading an RData file as its datasource into global. This powers reactive selection boxes, charts, data tables, etc, which change day by day. What I have in mind now is to generate a series of dated RData files as source files, and then ask the user to pick a data file to load through the UI prior to rendering the rest of the dashboard. It seems like this should be a fairly simple thing to accomplish, but I am at a loss. Do I need to modularize my shiny app, or can this be accomplished in some standard way? Thank you for any help.

Mike

Hi @griswomw. From your description, your UI design will be alternated by the data. If yes, I suggest modularise your app to make it clear to code. But if only data change and UI design not change, modules will make the app complicated.

I don't think this has anything to do with modularisation. You can do it fine in a single file app.

You will need to

  • read the file names (you can do this in the global section)
  • offer the file list to the user in the ui along with other default ui elements.
  • respond to the user's file selection in the server by loading the file, e.g. using observeEvent(input$chosen_file, {}), and then update the ui elements, e.g., updateSelectInput

Thank you, I appreciate the feedback from both of you. Simon-I will attempt to implement what you suggested and report back.

Regards,

Mike

Simon-

I've been able to use this to update UI elements like SelectInput, but I've been unable to figure out how to rerender the plotlyOutput with the new data. Any advice on this?

Thank you,

Mike

Hi Mike

I always use proxy for updating plotly (and DT). The main challenge is that plotlyProxyInvoke takes plotly arguments structured in the list structure of the underlying javascript, which was slightly modified in R-plotly. Basically you need to pass all arguments as nested lists. And if you get the list structure wrong you don't get an error, just nothing.

  output$bull_plot <- renderPlotly({
    plot_ly(...)
  })

  bull_plot_proxy <- plotlyProxy("bull_plot", session = session)

  observeEvent(..., {
    plotlyProxyInvoke(
          bull_plot_proxy, ...
    )
  })