Created
March 17, 2014 21:14
-
-
Save wch/9608492 to your computer and use it in GitHub Desktop.
conditionalPanel example for R Shiny
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
Type: Shiny | |
Title: conditionalPanel demo | |
License: MIT | |
Author: Winston Chang <[email protected]> | |
AuthorUrl: http://www.rstudio.com/ | |
Tags: conditionalpanel | |
DisplayMode: Showcase |
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
shinyServer(function(input, output) { | |
output$scatterPlot <- renderPlot({ | |
x <- rnorm(input$n) | |
y <- rnorm(input$n) | |
plot(x, y) | |
}) | |
}) |
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
shinyUI(fluidPage( | |
titlePanel("Conditional panels"), | |
column(4, wellPanel( | |
sliderInput("n", "Number of points:", | |
min = 10, max = 200, value = 50, step = 10) | |
)), | |
column(5, | |
"The plot below will be not displayed when the slider value", | |
"is less than 50.", | |
# With the conditionalPanel, the condition is a JavaScript | |
# expression. In these expressions, input values like | |
# input$n are accessed with dots, as in input.n | |
conditionalPanel("input.n >= 50", | |
plotOutput("scatterPlot", height = 300) | |
) | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment