Assignment 4 : Developmemt of Data Products using Shiny App

Sanjay Fuloria
06/30/2017

Plotting histograms for different distributions

  • The title is “Interactive Histogram”
  • The first input is to feed number of points to be plotted
  • The next input is to feed in the type of distribution
  • The number of bins can be changed using the slider

Slide With Code (ui.R)

library(shiny)

shinyUI(pageWithSidebar( headerPanel(“Interactive Histogram”), sidebarPanel( numericInput(“n”, “Generate this many points”, min = 1, value = 1000), selectInput(“family”, “From this family”, choices = c(“Normal”, “Uniform”, “Exponential”), selected = “normal”), sliderInput(“bins”, “number of bins”, min = 1, max = 100, value = 50) ), mainPanel( plotOutput(“histogram”) )

Slide With Code (Server.R)

library(shiny)

shinyServer(function(input, output) { data <- reactive({ FUN <- switch(input$family, “Normal” = rnorm, “Uniform” = runif, “Exponential” = rexp) FUN(input$n) })

output$histogram <- renderPlot({ hist(data(), breaks = input$bins) })

})

Link to my Shinyapp

Last Slide

Thank You