Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Shiny for R

Shiny for R

Why use Shiny and the basics of using Shiny with R Studio

Kevin O'Brien

August 01, 2015
Tweet

More Decks by Kevin O'Brien

Other Decks in Technology

Transcript

  1. Why Shiny Data to explore Alternative parameters or models to

    characterize data Allow for visual exploration of model fits
  2. How Shiny New R Project data & model source -

    server.R presentation and inputs - ui.R
  3. Shiny Project in R-Studio File > New Project New Directory

    > Shiny Web Application Directory Name: name for the new directory Create Project
  4. New Project Defaults: server.r variable x contains old faithful geyser

    data variable bins contains range of possible bin number hist() - defines a histogram for the variables output is ‘distPlot’
  5. New Project Defaults: ui.r sidebarPanel - sliderInput - value for

    the ‘bins’ variable mainPanel - show the ‘distPlot’
  6. Graph Data and a Model? Some data - x and

    y values a model - a polynomial equation y = mxn+b f(x) = a2 xn + a1 x + a0 where a1 is zero Play with the inputs to see what fits the data See References for Polynomial Project at github
  7. Polynomial project: server.r variables x and y contain 10 pairs

    where x = y x_prime is evaluated over the range -10 to 10 y_prime is calculated using the model (x, y) is plotted as points (x_prime, y_prime) is plotted as a line output is ‘polyPlot’
  8. Polynomial project: ui.r sidebarPanel - sliderInput - value for the

    ‘intercept’ b sliderInput - value for the ‘slope’ m sliderInput - value for the ‘degree’ n mainPanel - show the ‘polyPlot’
  9. References Polynomial Project: github… Shiny tutorial http:/ /shiny.rstudio.com/tutorial/lesson1/ Shiny Examples

    http:/ /www.showmeshiny.com Shiny Server on Amazon Cloud http:/ /www.stat.yale.edu/~jay/EC2/CreateFromScratch.html