Explore IRIS data

An interactive runApp

Coursera Student
Data analyst

Overviews

This app provids 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 whole app layout composes of two major parts, one is the sidepanel, which provides documentation for user and interface for users input. The other is main panel wich provide the tables and graphs output based on user's options.

User interface

It provides support documentation and a console for users to choose what they are interested. Once items have been chosen, corresponding summary tables and graphs will be presented on the right panel. Here is the sample code from ui.R.

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 choice, acutal calculation is done in server.R, given all necessary libraries have been loaded. Say, if you are interested in knowing characters of Specie 'Virginica', you will see following from the right upper panel once your select 'Virginica' from the console.

      kable(summary(iris[which(iris$Species=='virginica'),c(1,2,3,4)]))
Sepal.Length Sepal.Width Petal.Length Petal.Width
Min. :4.900 Min. :2.200 Min. :4.500 Min. :1.400
1st Qu.:6.225 1st Qu.:2.800 1st Qu.:5.100 1st Qu.:1.800
Median :6.500 Median :3.000 Median :5.550 Median :2.000
Mean :6.588 Mean :2.974 Mean :5.552 Mean :2.026
3rd Qu.:6.900 3rd Qu.:3.175 3rd Qu.:5.875 3rd Qu.:2.300
Max. :7.900 Max. :3.800 Max. :6.900 Max. :2.500

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, once you choose the petal from the console, the following graph will be present on the right lower panel.

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

plot of chunk unnamed-chunk-3