Data Product using Iris Dataset

Nazima
MArch 2016

Iris Flower Dataset

The Iris flower data set or Fisher's Iris data set is a multivariate data set introduced by Ronald Fisher in his 1936 paper The use of multiple measurements in taxonomic problems as an example of linear discriminant analysis.

  • 1. It is sometimes called Anderson's Iris data set because Edgar Anderson collected the data to quantify the morphologic variation of Iris flowers of three related species.
  • 2.Two of the three species were collected in the Gaspe Peninsula “all from the same pasture, and picked on the same day and measured at the same time by the same person with the same apparatus”“

Dataset Summary

The data set consists of 50 samples from each of three species of Iris (Iris setosa, Iris virginica and Iris versicolor). Four features were measured from each sample: the length and the width of the sepals and petals, in centimetres. Based on the combination of these four features, Fisher developed a linear discriminant model to distinguish the species from each other.

Attribute Information:

  1. sepal length in cm
  2. sepal width in cm
  3. petal length in cm
  4. petal width in cm
  5. class: – Iris Setosa – Iris Versicolour – Iris Virginica

Data Product Summary

Shiny app called irisfloweranalysis is helpful for the Analyst to study the data using different widgets.The data can be analysized in steps using the following widgets…

  • SelectInput : It gives user the choice to pick one of the quantitive variable from the data sets. The user can select from Sepal Length",“Sepal Width”,“Petal length”,“Petal Width”.
  • SliderInput : In the second choice it asks the user to selct the required amount of bins required for plotting the histogram for better analysis.
  • radioButtons : It allows the user to change the colot of the Histogram.
  • DownloadButton :
    User can dowload the generated plot in his device
  • radioButtons : It gives a choice to user to save the genrated plot either in png or pdf format.

IriSFlowerAnalysis (ui.R)

library(shiny)
data(iris)

# Define UI for application
shinyUI(fluidPage(

  # Application title
  titlePanel(title = h4("Developing data products Project using Iris flower Dataset", align = "center")),

  # Sidebar with a slider input for the number of bins
  sidebarLayout(
    sidebarPanel(
      h3('Instructions'),
      p('The data set consists of 50 samples from each of three species of Iris (Iris setosa, Iris virginica and   Iris versicolor). Four features were measured from each sample: the length and the width of the sepals and petals, in centimetres.'),
      selectInput("var","1. Select quantitative variable",choices = c("Sepal Length" = 1,"Sepal Width" = 2,"Petal length" = 3,"Petal Width" = 4)),
      br(),
      sliderInput("bins","2. Select the number of Bins for the Histogram", min = 5,max = 25, value = 15),
      br(),
      radioButtons("color","3. Select the color of histogram", choices=c("Red","Green","Yellow"), selected = "Green")
    ),
    # Show a plot of the generated distribution in the plotPutput()
    mainPanel(
      textOutput("text1"),
      textOutput("text2"),
      textOutput("text3"),
      tabsetPanel(type="tab",
                  tabPanel("Summary", verbatimTextOutput("sum")),
                  tabPanel("Structure", verbatimTextOutput("str")),
                  tabPanel("Data", tableOutput("data")),
                  tabPanel("Plot", plotOutput("myhist")),
                  downloadButton(outputId = "down",label = "Download Plot"),
                  radioButtons("type","Select the File type", choices=c("pdf","png"), selected = "pdf")

      )
    )
  ))
)

<!–html_preserve–>

Developing data products Project using Iris flower Dataset

Instructions

The data set consists of 50 samples from each of three species of Iris (Iris setosa, Iris virginica and Iris versicolor). Four features were measured from each sample: the length and the width of the sepals and petals, in centimetres.





Download Plot

<!–/html_preserve–>

IriSFlowerAnalysis (server.R)

library(shiny)
data(iris)

# Define server logic required to draw a histogram
# Expression that generates a histogram. The expression is
# wrapped in a call to renderPlot to indicate that:
#
#  1) It is "reactive" and therefore should be automatically
#     re-executed when inputs change
#  2) Its output type is a plot

shinyServer(

  function(input, output){

    colm <- reactive({
      as.numeric(input$var)
    })

    output$text1 <- renderText({
      #  colm = as.numeric(input$var)
      paste("Data set variable/colmn name is",names(iris[colm()]))
    })
    output$text2 <- renderText({
      paste("Color of histogram is", input$color)
    })

    output$text3 <- renderText({
      paste("Number of histogram BINs is", input$bins)
    })


    ## Define renderPrint function for Summary Tab. 
    output$sum  <- renderPrint({
      summary(iris)
    })

    ## Define renderPrint function for Structure Tab.
    output$str <- renderPrint({
      str(iris)
    })

    ## Define renderTable Function for user selcted column in the Data Tab.
    output$data <- renderTable({
      # colm <- as.numeric(input$var)
      iris[colm()]
      # head(iris)
    })

    ## Define the renderPlot function for the Plot Tab
    output$myhist <- renderPlot({
      # colm    <- as.numeric(input$var)

      # Draw the histogram with the specified number of bins
      hist(iris[,colm()], breaks = seq(0,max(iris[,colm()]),length.out = input$bins + 1),col = input$color,main = "Histogram of iris dataset",xlab = names(iris[colm()]))
    })


    output$down <- downloadHandler(
      # specify file name
      filename = function(){
        #iris.png
        #iris.pdf
        paste("iris",input$type, sep = '.')
      },

      content = function(file){
        #open the device
        #create the plot
        #close the plot
        #png()
        #pdf()

        if(input$type == "pdf")
          pdf(file)

        else

          png(file)
          plot(myhist())
        dev.off()

      })

  })