inst/hello-world/app.R

library(shiny)

# ==== Define UI ====
ui <- fluidPage(
  
  titlePanel("Hello Shiny!"),
  sidebarLayout(
    sidebarPanel(
      sliderInput(inputId = "bins", label = "Number of bins:",
                  min = 1, max = 50, value = 30)),
    mainPanel(plotOutput(outputId = "distPlot")))
)

# ==== Define server ====

server <- function(input, output) {
  
  output$distPlot <- renderPlot({
    
    x    <- faithful$waiting
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    hist(x, breaks = bins, col = "#75AADB", border = "white",
         xlab = "Waiting time to next eruption (in mins)",
         main = "Histogram of waiting times")
  })
}

# ==== run app ====
shinyApp(ui = ui, server = server)
Poduval/rshinytool documentation built on Dec. 18, 2021, 7:45 a.m.