An Interactive Explotory Tool

Shiny Application

Lihai Song
Data analyst

Overviews

This app is created using Shiny to provide a tool for explotory of IRIS data, it has following components:

  1. Documentation that helps users start
  2. User Interface layout in UI.R
  3. Actual operations in server.R
  4. Output of summary table and graphs

The Applicaiton layout composes of two major parts, one is the sidepanel, which provides documentation for user and an interactive interface for users to use. The other part is the main panel which outputs summary tables and graphs based on user's selections. Details explanation of user interfaces and outputs will be shown in following slides.

User interface

It provides support documentation and an interactive console for users to choose what they are interested. Once items have been selected, corresponding summary tables and graphs will be present on the right panel. Here is the sample code from ui.R. (Interactivity is not shown)

shinyUI(fluidPage(titlePanel("Summary and Patterns for different IRIS species"),
  sidebarLayout(sidebarPanel(
      includeMarkdown("README.Rmd"),
      selectInput("var1", 
                  label = "Choose a specie you are interested",
                  choices = c("Setosa", "Versicolor","Virginica"), 
                  selected = "Setosa" ),
      selectInput("var2", 
                  label = "Choose Petal/Sepal for graph",
                  choices = c("Petal", "Sepal"), 
                  selected = "Petal" ) ),
      mainPanel( tableOutput('summ'),plotOutput('plot2',width=600,height=350) )    )))

Summary table

The summary table is created based on user's interative selection, actual calculation is done inside server.R, given all necessary libraries have been loaded. Say, if you are interested in knowing Specie Virginica's character, your selection will be passed to server.R and after calculation, the following summary table will be present.

      kable(summary(iris[which(iris$Species=='virginica'),-c(5)]))
Sepal.Length Sepal.Width Petal.Length Petal.Width
Min. :4.90 Min. :2.20 Min. :4.50 Min. :1.40
1st Qu.:6.22 1st Qu.:2.80 1st Qu.:5.10 1st Qu.:1.80
Median :6.50 Median :3.00 Median :5.55 Median :2.00
Mean :6.59 Mean :2.97 Mean :5.55 Mean :2.03
3rd Qu.:6.90 3rd Qu.:3.17 3rd Qu.:5.88 3rd Qu.:2.30
Max. :7.90 Max. :3.80 Max. :6.90 Max. :2.50

Graph

After captureing user's input, graph is created within server.R. For instance, if you are interested in looking at scatter plot of Petal, server.R will generate a graph based on your selection and export it to the right lower panel of the application.

 library(ggplot2)
 qplot(y=Sepal.Width,x=Sepal.Length,data=iris,color=Species)

plot of chunk unnamed-chunk-3