Drawing A Histogram

M. Chellakumar
05-03-2019

  • We intend to draw a histogram based upon the input (number of random numbers to be generated)
  • As and when the number is selected on the slider the histogram is generated

You can find the UI.R and server.R files in the following link (gitbub repository) https://github.com/chellakumarmani/DevelopingDataProducts

This is UI.R page

library(shiny)

# Define UI for application that draws a histogram
shinyUI(fluidPage(

  titlePanel("Drawing Histogram for a selected count of random numbers"),

  # Sidebar with a slider input for choosing count of numbers 
  sidebarLayout(
    sidebarPanel(
       sliderInput("num",
                   "Choose a Number:",
                   min = 1,
                   max = 50,
                   value = 25
                   )
    ),

    # Show a plot of the generated distribution
    mainPanel(
       plotOutput("hist")
    )
  )
))

<!–html_preserve–>

Drawing Histogram for a selected count of random numbers

<!–/html_preserve–>

This is the Server.R page

library(shiny)

library(shiny)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

  output$hist <- renderPlot({

   hist(rnorm(input$num),col = 'darkgray', border = 'white')

  })

})