我正在尝试使用 shiny
包中的 conditionalPanel
函数构建一个 Shiny 的应用程序。条件应该用 JavaScript
编写,但我希望能够使用如下条件(用 R 编写)
"TP53" %in% unlist(input$ModelVariables)
文档说明:
condition - A JavaScript expression that will be evaluated repeatedly to determine whether the panel should be displayed.
我对 JavaScript
一点都不熟悉。我试过 input.ModelVariables == 'TP53'
但当 input.ModelVariables
的长度大于 1 时,这不起作用。
我的 sidebarPanel
片段和 conditionalPanel
在下面
checkboxGroupInput("ModelVariables",
label = h3("Which variables to view?"),
choices = list( "cohort",
"stage",
"therapy",
"TP53",
"MDM2" ),
selected = list("TP53")
),
conditionalPanel(condition = "'TP53' in unlist(input.ModelVariables)",
checkboxGroupInput("ModelVariablesTP53",
label = h3("Which mutations to view?"),
choices = list( "Missense",
"Other",
"WILD"),
selected = list("Missense",
"Other",
"WILD")
)
最佳答案
根据 this answer这种情况应该有效(并且对我有效)
条件 = "input.ModelVariables.indexOf('TP53') > -1"
关于javascript - Shiny 的 conditionalPanel javascript 条件 : is there R %in% operator in javascript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29637285/