Easy Interactive Dashboards
With R & Shiny

Aaron Williams [awilliams@urban.org]


Alex Engler [aengler@urban.org]

Motivation 1: Exploratory Data Analysis

DYNASIM

6 years of mean income estimates

19 Social Security reforms modelled in DYNASIM

4 types of income

64 demographic levels

2 baselines

2 scales

3 comparisons

6 X 19 x 4 x 64 x 2 x 2 x 3 = 350,208 means (observations)

19 x 4 x 64 x 2 x 2 x 3 = 58,368 combination of categorical variables

DYNASIM Shiny Example 2

Motivation 2: Conferences and Talks

R Shiny extends directly to an analysis tool:

PAG Bayesian Analytical Model

Motivation 3: Mock-ups for Comms or Lightweight Features

DYNASIM Shiny Example 1

Stop, Disclaimer, Warning:

Before starting any work for Urban.org, please contact:

  • Ben Chartoff
  • David Connell
  • John Wehmann
  • DEMO!

    Four Parts of a Shiny Interactive:

  • Global Objects and Packages
  • User Interface (local or online)
  • Server (R session)
  • shinyApp (ties 1. and 2. together)
  • Template

    library(shiny)

    ui <- fluidPage()

    server <- function(input, output){}

    shinyApp(ui = ui, server = server)

    Global Objects

    library()

    data sets

    Runs Once

    User Interface (inputs and outputs)

    *Input() functions (create input$<id> objects)

  • selectInput()
  • sliderInput()
  • *Output() functions (display output$<id> objects)

  • plotOutput()
  • Server (R session)

    Reactivity

  • when input$<id> changes, the server reacts
  • when output$<id> changes, the ui reacts
  • render*({}) functions (create output$<id> objects)

  • renderPlot({})
  • Common Mistakes

    Commas

    Parentheses

    renderPlot({ })

    inputId not inputID

    quoted and unquoted objects

    How We Made This Easier for You

    Urban Institute ggplot2 theme

    Lots of Examples!

    Cascading Style Sheets

    Continuous Deployment with Codeship and Github

    Credit to: Dave D'Orio

    Continuous Deployment with Codeship and Github Asks:

    To request an R package for the Shiny server, please request it using GitHub issues

    So what do you need to know?

    • R / Shiny / ggplot2
    • Git / GitHub

    More Resources

    Digital

    Human

    Aaron Williams (awilliams@urban.org)