shinydashboard, shny.router - advise on clean code structure for handling large project


Before moving forward in my project, I clearly need help in order not to rush in the code and start something ridiculously complex while it could be easier to handle.

I describe here below what I have to deal with and would like advise on the best way to handle the task.

I have a DT with many products (let say 100 for example).

The user can choose one of them and will be able to perform some analysis based on his/her choice.
Once he has chosen the product, I would like him to click on a button and be redirected to a page with another dashboard that fully depends on the product he has chosen.

I coded the first dashboard to be able to perform the product selection with a couple of features but I am not sure how to handle the next step.

I would also like the user to be able to go back easily to the selection dashboard and analyse another product.

I thought about creating a menu item when the user clicks on an action button and he would be redirected directly to this menu item. However, I don't want my dashboardBody to be 1.000.000 lines long. Also, I don't want more than X menu items to be created. That looks messy and not optimal. Is there any way to code each tab item in a separate code or anything like this?

I also thought about using shiny.router to redirect the user to another page hosting a dashboard corresponding to the product he has chosen. Would that be possible? I have tried to test it but without success.

Any help appreciated! Have to go back to it tomorrow and I am a bit lost at the moment :slight_smile:

Thank you vm


The first thing I would recommend is modularizing your Shiny app code. See this RStudio article for a good overview:

A Shiny module is a piece of a Shiny app. It can’t be directly run, as a Shiny app can. Instead, it is included as part of a larger app (or as part of a larger Shiny module–they are composable).

Modules can represent input, output, or both. They can be as simple as a single output, or as complicated as a multi-tabbed interface festooned with controls/outputs driven by multiple reactive expressions and observers.

Once created, a Shiny module can be easily reused–whether across different apps, or multiple times in a single app (like a set of controls that needs to appear on multiple tabs of a complex app). Modules can even be bundled into R packages and used by other Shiny authors. Other Shiny modules will be created that have no potential for reuse, by simply breaking up a complicated Shiny app into separate modules that can each be reasoned about independently.

I also found @colin's "Building Big Shiny Apps - A Workflow" and { golem } package both very useful for implementing large, modular shiny apps in packages and containers.

Hi Maxime. Could you provide some (dummy) data of your products and stuff examples of stuff you'd like to do with it (ie plotting, whatever analysis or regression you have in mind)? What you already mentioned sounds like a task that can be acomplished by one, or few tabs in shinydashboard given that all the data are in one table/database.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.