Lakshmi Kovvuri
August 22,2020
This Rmarkdown presentation is about Iris dataset from the datasets package. Here I used Shiny application to check the iris data attribute measurements with the help of histogram.
In Shiny application the file ui.R gives the information about slider bar and option to choose the attribute, where as the server.R gives the information to build the histogram for the iris attribute.
The iris dataset contains 50 samples of 3 different species of iris.
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
## Warning: package 'shiny' was built under R version 4.0.2
# Define ui for Iris data that draws a histogram
ui <- fluidPage(
titlePanel("Iris Data Explorer"),
# Sidebar with radio buttons for attribute option and a slider input for bins range
sidebarLayout(
sidebarPanel(
helpText("Select the attribute to know the variation of each measurement "),
radioButtons("option", "Choose Iris attribute:", list("Sepal.Length"='a', "Sepal.Width"='b', "Petal.Length"='c', "Petal.Width"='d')),
sliderInput("bins",
"Slide me to check the histogram of each attribute",
min = 1,
max = 50,
value = 30)
),
# Visualization of Iris Dataset through Histogram
mainPanel(
mainPanel(plotOutput("distPlot"))
)
)
)server <- function(input, output) {
output$distPlot <- renderPlot({
if(input$option=='a'){
i<-1 }
if(input$option=='b'){
i<-2 }
if(input$option=='c'){
i<-3 }
if(input$option=='d'){
i<-4 }
# generate bins based on input$bins from ui.R
x <- iris[, i]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified bins range
hist(x, main = "Histogram of Iris Dataset", xlab = "Iris Attribute", ylab = "Frequency", breaks = bins, col = 'blue', border = 'white')
})
}https://lakshmikovvuri.shinyapps.io/DataProducts-finalProject/
https://github.com/Lakshmi-Kovvuri/DataProducts-finalProject