EVOLUTION-MANAGER
Edit File: conditionalPanel.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Conditional Panel</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for conditionalPanel {shiny}"><tr><td>conditionalPanel {shiny}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Conditional Panel</h2> <h3>Description</h3> <p>Creates a panel that is visible or not, depending on the value of a JavaScript expression. The JS expression is evaluated once at startup and whenever Shiny detects a relevant change in input/output. </p> <h3>Usage</h3> <pre> conditionalPanel(condition, ..., ns = NS(NULL)) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>condition</code></td> <td> <p>A JavaScript expression that will be evaluated repeatedly to determine whether the panel should be displayed.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Elements to include in the panel.</p> </td></tr> <tr valign="top"><td><code>ns</code></td> <td> <p>The <code><a href="NS.html">namespace()</a></code> object of the current module, if any.</p> </td></tr> </table> <h3>Details</h3> <p>In the JS expression, you can refer to <code>input</code> and <code>output</code> JavaScript objects that contain the current values of input and output. For example, if you have an input with an id of <code>foo</code>, then you can use <code>input.foo</code> to read its value. (Be sure not to modify the input/output objects, as this may cause unpredictable behavior.) </p> <h3>Note</h3> <p>You are not recommended to use special JavaScript characters such as a period <code>.</code> in the input id's, but if you do use them anyway, for example, <code>inputId = "foo.bar"</code>, you will have to use <code>input["foo.bar"]</code> instead of <code>input.foo.bar</code> to read the input value. </p> <h3>Examples</h3> <pre> ## Only run this example in interactive R sessions if (interactive()) { ui <- fluidPage( sidebarPanel( selectInput("plotType", "Plot Type", c(Scatter = "scatter", Histogram = "hist") ), # Only show this panel if the plot type is a histogram conditionalPanel( condition = "input.plotType == 'hist'", selectInput( "breaks", "Breaks", c("Sturges", "Scott", "Freedman-Diaconis", "[Custom]" = "custom") ), # Only show this panel if Custom is selected conditionalPanel( condition = "input.breaks == 'custom'", sliderInput("breakCount", "Break Count", min = 1, max = 50, value = 10) ) ) ), mainPanel( plotOutput("plot") ) ) server <- function(input, output) { x <- rnorm(100) y <- rnorm(100) output$plot <- renderPlot({ if (input$plotType == "scatter") { plot(x, y) } else { breaks <- input$breaks if (breaks == "custom") { breaks <- input$breakCount } hist(x, breaks = breaks) } }) } shinyApp(ui, server) } </pre> <hr /><div style="text-align: center;">[Package <em>shiny</em> version 1.5.0 <a href="00Index.html">Index</a>]</div> </body></html>