Exploratory app

Temilade Sorungbe

12 December 2016

Description

This Shiny App performs the following exploratory analyses on the cars dataset: data summary, data distribution and boxplot. Below are the user interface and server codes used to generate this app.

Exploratory App - User Interface (UI) code

library(shiny)
ui = fluidPage(
  sidebarLayout(
    sidebarPanel(
      selectInput("analysis", 
                  label = "Choose a type of exploratory analysis:", 
                  choices = c("Data Summary", "Histogram", "Boxplot"),
                  selected = "Histogram"),
    submitButton("Update View")),
  mainPanel(
      h4("Data Summary"),
      tableOutput("summary"),
      h4("Histogram"),
      plotOutput("Histogram"),
      h4("Boxplot"),
      plotOutput("Boxplot")
    )
  )
)

Exploratory App - Server code

server = function(input, output) {
  analysisInput <- reactive({
    switch(input$analysis,
           "Histogram" = 1, "Boxplot" = 2, "Data Summary" = 3) })
  output$summary <- renderPrint ({ 
    analysis <- analysisInput()
    if (analysis == 3) {summary(cars)}   })
  output$Boxplot <- renderPlot ({ 
    analysis <- analysisInput()
    if (analysis == 2) {
      boxplot(cars) 
      title(main = "1920s Cars - Boxplot", ylab = "Speed (mph)")} })
  output$Histogram <- renderPlot({
    analysis <- analysisInput()
    if (analysis == 1) {
    par(mfcol= c(1,2), oma=c(4,2,4,2))  
    hist(cars[,1], breaks = 10, col = 'darkgray', border = 'white',
      main = "1920s Cars - Distribution",
      xlab = "Speed (mph)")
    hist(cars[,2], breaks = 10, col = 'darkgray', border = 'white',
      main = "1920s Cars - Distribution",
      xlab = "Distance(ft)") }  
    }) 
}

Examples

The following are example outputs of the exploratory app using the chick weight dataset.

Data summary of chick weights

##      weight             feed   
##  Min.   :108.0   casein   :12  
##  1st Qu.:204.5   horsebean:10  
##  Median :258.0   linseed  :12  
##  Mean   :261.3   meatmeal :11  
##  3rd Qu.:323.5   soybean  :14  
##  Max.   :423.0   sunflower:12

The App

Click on the link below to use the exploratory app

https://tadelore.shinyapps.io/CourseProject/