Skip to content

Instantly share code, notes, and snippets.

@przytu1
Created May 16, 2017 21:22
Show Gist options
  • Save przytu1/ccf7609f7088d9ee4266d84dba6e5499 to your computer and use it in GitHub Desktop.
Save przytu1/ccf7609f7088d9ee4266d84dba6e5499 to your computer and use it in GitHub Desktop.
Classic Shiny app (blocking)
library(shiny)
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
actionButton("MakePlot", "MakePlot")
),
# Show a plot of the generated distribution
mainPanel(
fluidRow(
column(6, plotOutput("distPlot")),
column(6, plotOutput("FuturePlot")))
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$FuturePlot <- renderPlot({
input$MakePlot
Sys.sleep(5)
plot(cbind(rnorm(1000), rnorm(1000)))
})
}
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment