--- title: "MyShiny_pitch" author: "Aniket Porje" date: "February 10, 2018" output: html_document runtime: shiny --- Reproducible Pitch Presentation

Reproducible Pitch Presentation

Aniket Porje
Feb 11th 2018

Goal of this presentation

For this project we make a reactive histogram using the iris dataset that comes with R. We will use the render plot() function to render the plot and the plotOutput() function in the shiny UI to display the plot. We will also use the input widgets learned so far: selectInput(), sliderInput() and radioButtons(), especially the radio button to display the different colors.

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.

The URL:-https://stryvers.shinyapps.io/My_Reproducible_Shiny_App/

Slide With Code

data(iris)
str(iris)
'data.frame':   150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...

UI.R

library(shiny) 
# Define UI for application that draws the Distribution histogram
shinyUI(fluidPage(                                                                                                                                                                                                                                                     
  # Application header
  titlePanel(title = h4("Iris Dataset Render Plot() ", align="center")),
  sidebarLayout(
    # Sidebar panel
    sidebarPanel(
      selectInput("var","1. Select the variable from the iris dataset",
                  choices = c("Sepal.Length" = 1, "Sepal.Width" = 2, "Petal.Length" = 3, "Petal.Width" = 4),selected = 1),
      br(),
      sliderInput("bins", "2. Select the number of BINs for histogram", min=5, max=25, value=15),
      br(),
      radioButtons("color", "3. Select the color of histogram",
                   choices = c("Sky blue", "Red", "Green"), selected = "Sky blue")
    ),
    # Main Panel    
    mainPanel(
      plotOutput("myhist")
    )
  )
)
)

<!–html_preserve–>

Iris Dataset Render Plot()



<!–/html_preserve–>

SERVER.R

 library(shiny)
 shinyServer(
  function(input, output){
    output$myhist <- renderPlot({
      colm <- as.numeric(input$var)
      hist(iris[,colm], breaks=seq(0, max(iris[,colm]), l=input$bins+1),col=input$color, main="Histogram of Iris dataset", xlab=names(iris[colm])) 
    })
  }
 )