简体   繁体   English

Shiny 带矢量的条件输入面板

[英]Shiny conditional input panel with vector

I am looking to create a conditional panel in shiny that becomes active if the input that user selects from a list (ie selectInput function) belongs to another vector.我希望在 shiny 中创建一个条件面板,如果用户从列表中选择的输入(即 selectInput 函数)属于另一个向量,该面板将变为活动状态。

I am aware that the condition in the conditional panel is a javascript element, however I cannot make it work.我知道条件面板中的条件是 javascript 元素,但我无法使其工作。

Can someone help?有人可以帮忙吗?

Here is the UI part of the code under examination:这是正在检查的代码的 UI 部分:

legs1 <- c("HOUSE","VILLA","ATTICO")

selectInput("strategy", "Strategy:", choices = df[,6]),

conditionalPanel(
           
          condition = 'input.strategy && input.strategy.indexOf("legs1") > -1',
                              
          textInput("Leg1", "Leg1",value = ""),
          textInput("Leg2","Leg2", value =""),
          
          ),

If you don't have to access the vector from within the condition it should work by using如果您不必从条件内访问向量,它应该通过使用

condition = "input.strategy && ['HOUSE', 'VILLA', 'ATTICO'].indexOf(input.strategy) > -1"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM