Interactivly Loading Shiny Modules

Nov 24, 2018 00:00 · 309 words · 2 minute read R Shiny


If you want to see the implemented solution, please refer to: GitHub repo.


Shiny is a widely popular web application framework for a R. In simple tearms it enables any R programmer to develop and deploy web application. This application could be simple - an interactive document consiting of a few charts and tables or a c complex “behemoth” with multiple functionalities enabling end-users to run models, query external data, generate exportable reports and sophisticated visuals.

In business, it is frequently efficient to capitalise on existing solution and develop / upgrade existing products. In a business intelligence web application context this may mean adding modules and functionalities to an existing application so a wider audiance can be served and more user needs can be met.

This has certain advanatges, mostly:

  • Deployment cycle is faster, we are working on an existing product and adding new functionalities
  • We are leveraging existing dissemination mechanism, authentication, server, data connections. Where possible we can use tested and working solutions. This is conducive to stability.
  • Testing will be easier as we have an established user group that is familiar with the product


Challenges are more interesting, as this is what I’m going to discuss. The challenges can be groupped in two main themes:

  • Development
  • User exeperience


Let’s address development challenges first. Traditionally Shiny application would consist of server.R and ui.R. Each file containing function definitions for server and user interface. Recently both of those are saved as in one file as in examples provided with Shiny package. To see available examples run:

    path = system.file("examples", package = "shiny"),
    pattern = glob2rx("*.R"),
    recursive = TRUE,
    full.names = TRUE

Now this won’t fly. Best case scenario we will end-up with sphagetti code mostly likely we will end up with nothhing.


Modueles solve that problem by breakig down application architecture into