反应性更改后,继续显示条件面板

时间:2019-07-12 18:25:57

标签: javascript r shiny

我有一个条件面板,用于更新其条件。但是,我需要该面板即使在更新后也要保持显示状态

我尝试添加一个依赖于条件面板输入的附加条件。我还尝试将条件输入添加到条件

library(shiny)
ui <- fluidPage(
     title = 'Time inputs in Shiny',
     div( id = "eg1",
          fluidRow(
               radioButtons("ca",
                            "choices",
                            c("A", "B", "C", "D", "E"),
                            "B",
                            inline = T),
               conditionalPanel(
                    condition = "input.ca == 'C' || input.ca == 'D' || input.ca == 'E'",
                    radioButtons("cb", "test",
                                 c("Positive", "Negative"), "", inline = T)
               )
          )

     )
)

server <- function(input, output, session) {
     observe({

          if(!is.null(input$cb)){
               if(input$cb == "Positive"){
                    updateRadioButtons(session, "ca",
                                       "choices",
                                       c("A", "B", "C", "D", "E"),
                                       "A",
                                       inline = T)
               } else if(input$cb == "Negative"){
                    updateRadioButtons(session, "ca",
                                       "choices",
                                       c("A", "B", "C", "D", "E"),
                                       "B",
                                       inline = T)
               }
          }
     })
}



shinyApp(ui = ui,server = server)

按预期,条件面板将在更新后消失

0 个答案:

没有答案