Created
January 25, 2013 22:21
-
-
Save cpsievert/4638469 to your computer and use it in GitHub Desktop.
Hello Shiny Example (for demonstration)
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
#Taken from http://rstudio.github.com/shiny/tutorial/#hello-shiny | |
#All credits to Joe Cheng | |
library(shiny) | |
# Define server logic required to generate and plot a random distribution | |
shinyServer(function(input, output) { | |
# Function that generates a plot of the distribution. The function | |
# is wrapped in a call to reactivePlot to indicate that: | |
# | |
# 1) It is "reactive" and therefore should be automatically | |
# re-executed when inputs change | |
# 2) Its output type is a plot | |
# | |
output$distPlot <- reactivePlot(function() { | |
# generate an rnorm distribution and plot it | |
dist <- rnorm(input$obs) | |
hist(dist) | |
}) | |
}) |
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
#Taken from http://rstudio.github.com/shiny/tutorial/#hello-shiny | |
#All credits to Joe Cheng | |
library(shiny) | |
# Define UI for application that plots random distributions | |
shinyUI(pageWithSidebar( | |
# Application title | |
headerPanel("Hello Shiny!"), | |
# Sidebar with a slider input for number of observations | |
sidebarPanel( | |
sliderInput("obs", | |
"Number of observations:", | |
min = 0, | |
max = 1000, | |
value = 500) | |
), | |
# Show a plot of the generated distribution | |
mainPanel( | |
plotOutput("distPlot") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment