【问题标题】:Turn off ggvis output if radiobutton is selected如果选择了单选按钮,则关闭 ggvis 输出
【发布时间】:2015-10-17 09:53:35
【问题描述】:

我有一个单选按钮,我想在我的 ui.R 文件中使用它来打开和关闭 ggvis 绘图。当单选按钮设置为打开时,我将显示 ggvis 图。当它关闭时,我想显示一个表格输出。我有以下代码。

if(input$check==on){
vis %>% bind_shiny("plot1")}

我收到以下错误。

Operation not allowed without an active reactive context.

我想知道如何检查 input$check(收音机是否打开)然后决定显示 ggvis,否则显示表格。

【问题讨论】:

    标签: r ggvis shiny


    【解决方案1】:

    使用conditionalPanel。见http://shiny.rstudio.com/reference/shiny/latest/conditionalPanel.html

    这是我的ui.R 文件之一中的示例:

    sidebarPanel(
            radioButtons("compare", "Select By Date or Price",
                         c("Previous Date", "Price Change"), selected = "Previous Date"),
            br(),
            conditionalPanel(condition = "input.compare == 'Previous Date'",
              uiOutput("date_selected")
              ),
            conditionalPanel(condition = "input.compare == 'Price Change'",
              numericInput("price_change", "Enter Price Change %", 0, -100, 100)
              )
            )
    

    只需更改output

    【讨论】:

      猜你喜欢
      • 2017-09-02
      • 2020-11-08
      • 2019-12-13
      • 1970-01-01
      • 2014-08-19
      • 2011-11-05
      • 1970-01-01
      • 2012-12-28
      • 1970-01-01
      相关资源
      最近更新 更多