Last active
December 19, 2015 12:09
-
-
Save arthur-flam/5953230 to your computer and use it in GitHub Desktop.
Premier exemple. Merci RStudio !
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
shinyServer(function(input, output) { | |
output$main_plot <- renderPlot({ | |
hist(faithful$eruptions, | |
probability = TRUE, | |
breaks = as.numeric(input$n_breaks), | |
xlab = "Duration (minutes)", | |
main = "Geyser eruption duration") | |
if (input$individual_obs) { | |
rug(faithful$eruptions) | |
} | |
if (input$density) { | |
dens <- density(faithful$eruptions, | |
adjust = input$bw_adjust) | |
lines(dens, col = "blue") | |
} | |
}) | |
}) |
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
shinyUI(bootstrapPage( | |
selectInput(inputId = "n_breaks", | |
label = "Number of bins in histogram (approximate):", | |
choices = c(10, 20, 35, 50), | |
selected = 20), | |
checkboxInput(inputId = "individual_obs", | |
label = strong("Show individual observations"), | |
value = FALSE), | |
checkboxInput(inputId = "density", | |
label = strong("Show density estimate"), | |
value = FALSE), | |
plotOutput(outputId = "main_plot", height = "300px"), | |
# Display this only if the density is shown | |
conditionalPanel(condition = "input.density == true", | |
sliderInput(inputId = "bw_adjust", | |
label = "Bandwidth adjustment:", | |
min = 0.2, max = 2, value = 1, step = 0.2) | |
) | |
)) | |
# example from http://www.rstudio.com/shiny/ | |
# all credits to them |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment