Getting Started with Shiny
Publishing

Colin Rundel

Deploying Shiny apps

shinyapps.io

If you have not done so already - go to shinyapps.io and sign up for an account.

  • You can create a new account via email & a password

  • or via OAuth through Google or GitHub.

If asked to pick a plan, use the Free option (more than sufficient for our needs here)

Posit Cloud

Or deploy your app directly from Posit Cloud… to Posit Cloud!

Organizing your app

For deployment generally apps will be organized as a single folder that contains all the necessary components (R script(s), data files, other static content).

  • Pay attention to the nature of any paths used in your code

    • Absolute paths are almost certainly going to break

    • Relative paths should be to the root of the app folder

  • Static files (e.g. css, js, images, etc.) generally are placed in the www/ subfolder

  • Your script does not need to be named app.R or ui.R/server.R

  • Check / think about package dependencies

Your turn - Exercise 08

Now we will publish one of the demo apps to shinyapps.io (or posit.cloud)

  1. Pick your favorite demo or exercise from today and package it up either as an app in exercises/ex08app (you will need to create this folder)

    • Make sure to copy the data (data/weather.csv) into this folder
    • and adjust any paths if necessary
  2. Open the script file in exercises/ex06app and click the Publish Document button in the upper right of the pane (look for the icon)

    • You should be presented with the “Publish to server”, click on the Add New Account link in the upper right

    • Select shinyapps.io and follow the instructions to connect

    • When retrieving your token for shinyapps.io you may need to click Dashboard first and then your name (both in the upper right)

Your turn - Exercise 06 (cont.)

  1. Once authenticated you should be back at the “Publish to server” dialog, use this to select which files to include (select your script and data file)

  2. Your Shiny app should now be deploying and should open on shinyapps.io once live - check to see if everything works, if not go back and check Steps 1 and 3.

10:00

Other publishing options

  • For other R users - you can share your script(s) and data directly

    • or better yet, bundle them into an R package
  • Run a local instance of shiny server

  • Use shinyapps.io (public) or posit.cloud (within team)

  • License Posit Connect