Shiny (R)#

To deploy a Shiny R application to Ploomber Cloud you need:

  • A Ploomber Cloud account

  • A startApp.R file (a script to start the App)

  • An install.R file (a script to install dependencies)

  • An app.R file (your Shiny code)

If you have specific requirements for your application you may also use Docker for a customized deployment. This would enable you to use specific Shiny Docker image as well as run instructions specific for your application. Here is a sample Docker-based Shiny R application.

Required files#

You can use this template to get started. The startApp.R will remain the same, but you need to modify install.R and app.R.

In the install.R file, add all the dependencies that you need for your application to run. And put your application logic in the app.R file.

Testing locally#

To test your Shiny app, you can run the following commands locally:

# Install dependencies
Rscript install.R

# Start the application
Rscript startApp.R

Deploy#

Deploy from the menu

Once you have all your files, create a zip file.

To deploy a Shiny app from the deployment menu, select the Shiny (R) option and follow the instructions:

Try an example

To download and deploy an example Shiny-R application start by installing Ploomber Cloud and setting your API key:

pip install ploomber-cloud
ploomber-cloud key YOUR-KEY

Tip

If you don’t have an API key yet, follow the instructions here.

Now, download an example. It will prompt you for a location to download the app. To download in the current directory, just press enter.

ploomber-cloud examples shiny-r/shiny-r-data-visualization

Note

A full list of Shiny-R example apps is available here.

You should see a confirmation with instructions on deploying your app. Now, navigate to your application:

cd location-you-entered/shiny-r-data-visualization

Deploy from the CLI

Initialize and deploy your app with:

ploomber-cloud init
ploomber-cloud deploy --watch

Features#

Ploomber Cloud supports many features to help you build R Shiny applications quickly!

Troubleshooting#

Some R packages depend on C libraries, which are not installed by default. For example, the igraph R package depends on the GLPK library. If you try to run library(igraph) without installing GLPK, you’ll see this error:

Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/site-library/igraph/libs/igraph.so':
libglpk.so.40: cannot open shared object file: No such file or directory

To fix this, you can use the Docker deployment option and install GLPK, here’s an example. To learn more, see the Docker deployment instructions.

If you need help installing certain libraries, email us at contact@ploomber.io

Examples#

App with igraph
Data visualization