Nazima
MArch 2016
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.
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:
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…
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–>
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()
})
})