【问题标题】:Linking sidebarPanels in shiny for SelectizeInput function为 SelectizeInput 函数链接 sidebarPanels
【发布时间】:2016-12-12 03:50:03
【问题描述】:

假设我在sidebarPanel - location 中有一个下拉菜单,我最多可以从中选择 2 个选项。我想创建一个 if 循环,其中从下拉列表中选择“鞍形接头”和“滑动接头”会导致在另一个 sidebarPanel - datasets 中选择对象“x”和“y”——基本上是创建一个链接。

我尝试了这段代码,但它不起作用:

if (input$location== "Saddle Joint" & input$location== "Gliding Joint") {

  updateCheckboxGroupInput(session,
                           "datasets", "Datasets:", choices = c("x","y"),
                           selected= c("x","y"))
}

请看截图以获得更好的图片!

谢谢!

Screenshot

【问题讨论】:

  • 你的 if 语句永远不会是真的,因为input$location 不能同时等于鞍形接头和滑动接头。如果input$location 是一个具有多个值的向量,那么您需要"Saddle Joint" %in% input$location & "Glding Joint" %in% input$location
  • @Carl 有效!谢谢!
  • 好的,然后提交答案。
  • @Carl 如果我有一个名称向量,假设例如:as,ad,af.. 等等。我如何确定两个 (as,ad; as,af, ad,af) 的组合,以便我可以将其插入到 if 循环中,例如 if(input$location==all combination of the vector).. 然后执行此操作

标签: shiny shiny-server shinydashboard shinyjs


【解决方案1】:

问题在于您的 if 语句中的布尔值。使用这个:

"Saddle Joint" %in% input$location & "Gliding Joint" %in% input$location

也可以使用:

all(c("Saddle Joint","Gliding Joint") %in% input$location)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    • 2013-05-22
    • 2014-10-04
    • 2015-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多