11.3 Example for starters

  1. Create a directory/folder where you save all the course files
  2. Within that directory create a subdirectory for the app with the name shinyapp1
    • dir.create("./www/apps/shinyapp1/", recursive = TRUE)
  3. Set your working directory to this (app) directory
    • setwd("www/apps/shinyapp1")
  4. A shiny app requires one source file (several if you want)
    • This file includes the user interface (UI) and the server (SERVER, code to evaluate inputs and generate outputs)
    • File(s) must be saved in app directory
  5. Create one script (“File -> New File -> R script”) in which you paste the code below and save that script under the name app.R (DON’t USE ANOTHER NAME). In this example there is just one reactive output, namely a plot.
  1. Open script and run the app locally (e.g. paste in console, push run or paste code below)
  • If that works…
  1. Deploy app online on shinyapp.io: Push button “publish” in app window or code below
  1. Visit app online!