Created
May 16, 2017 21:22
-
-
Save przytu1/ccf7609f7088d9ee4266d84dba6e5499 to your computer and use it in GitHub Desktop.
Classic Shiny app (blocking)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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