conditionalPanel: Conditional Panel

Description Usage Arguments Details Note Examples

View source: R/bootstrap.R

Description

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.

Usage

1

Arguments

condition

A JavaScript expression that will be evaluated repeatedly to determine whether the panel should be displayed.

...

Elements to include in the panel.

Details

In the JS expression, you can refer to input and output JavaScript objects that contain the current values of input and output. For example, if you have an input with an id of foo, then you can use input.foo to read its value. (Be sure not to modify the input/output objects, as this may cause unpredictable behavior.)

Note

You are not recommended to use special JavaScript characters such as a period . in the input id's, but if you do use them anyway, for example, inputId = "foo.bar", you will have to use input["foo.bar"] instead of input.foo.bar to read the input value.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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=1000, value=10)
      )
   )
)

ymd526442121/Rproject_shiny documentation built on May 4, 2019, 5:31 p.m.