March 23, 2017

Getting Started

Access resources from CBCC website

  • Create a new folder for storing your shiny apps.
  • Place Hospitals.csv dataset in the new folder
  • Place hospitalApp.zip in new folder and unzip
  • Set your working directory to that folder
  • Install shiny, refund, and refund.shiny libraries
# set working directory to be the folder you just created
setwd("/Users/juliawrobel/Documents/How to use Shiny/")

# install libraries
install.packages("shiny")
install.packages("refund.shiny")
install.packages("refund")

Shiny is a framework in R for building interactive plots and web applications

library(shiny)
runExample("01_hello")
runExample("03_reactivity")

Run the code above to see two examples of shiny apps

Each shiny app has a ui and a server

ui

  • controls layout and appearance
  • where you add widgets
  • ui.R

server

  • instructions your computer needs to build the app
  • R code for plots, etc.
  • server.R

You can initialize a Shiny app right from RStudio

Drawing

Drawing

Choose a name for your app, set the directory, and click Create.

A Shiny app is now stored in the directory you chose