Created
September 23, 2013 16:35
-
-
Save garrettgman/6673251 to your computer and use it in GitHub Desktop.
A very simple Shiny App
This file contains hidden or 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) | |
shinyServer(function(input, output) { | |
data <- reactive({ | |
FUN <- switch(input$family, | |
"Normal" = rnorm, | |
"Uniform" = runif, | |
"Exponential" = rexp) | |
FUN(input$n) | |
}) | |
output$histogram <- renderPlot({ | |
hist(data(), breaks = input$bins) | |
}) | |
}) |
This file contains hidden or 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) | |
shinyUI(pageWithSidebar( | |
headerPanel("Interactive Histogram"), | |
sidebarPanel( | |
numericInput("n", "Generate this many points", | |
min = 1, value = 1000), | |
selectInput("family", "From this family", | |
choices = c("Normal", | |
"Uniform", | |
"Exponential"), | |
selected = "normal"), | |
sliderInput("bins", "number of bins", | |
min = 1, max = 100, value = 50) | |
), | |
mainPanel( | |
plotOutput("histogram") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment