Skip to article frontmatterSkip to article content

Shiny is a platform that makes it easy to build interactive web apps. R shiny server in DataHub is used to build interactive dashboards.

Short demo of Shiny application on DataHub

Figure 1:Short demo of Shiny application on DataHub

If you are interested to explore Shiny application further then you can play with examples from Posit and some from a Stat instructor.

Distributing and Running Shiny Apps

You can use nbgitpuller to distribute a Shiny application. You need to specify the full path to the shiny app which includes the targetpath parameter. This parameter sets the destination directory for your Shiny app.

The targetpath parameter is important for Shiny applications because jupyter-shiny-proxy (a Jupyter extension that allows users to run R Shiny applications directly from their Jupyter environment) looks for Shiny apps in specific locations in user’s environment, such as ~/ShinyApps/.

Setting the appropriate target path ensures that your Shiny app will be discoverable and properly launched by the proxy service. Without specifying this parameter, your Shiny applications may not be accessible to users after cloning.

For example if the application exists in course-repo/app1, the nbgitpuller custom URL would be shiny/course-repo/app1.

https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=<repository-url>&branch=<branch-name>&targetpath=<target-directory>

Here is an example link that launches Shiny application in R-staging hub,

https://r.datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fds-modules%2Fpolisci-3&branch=main&urlpath=shiny%2Fpolisci-3%2FModule_8_Regression%2F&targetPath=ShinyApps/polisci-3

Users can also run Shiny from the JupyterLab launcher. This will display a shiny file browser.

Shiny launcher button.

Figure 2:Shiny launcher button.

Manual Application Installation

Example

Explore Shiny Dashboard

Figure 3:Explore Shiny Dashboard

You can also view the code that generated the dashboard in the rendered output.

Code that generates Shiny dashboard

Figure 4:Code that generates Shiny dashboard