javascript - Shiny 的 conditionalPanel javascript 条件 : is there R %in% operator in javascript?

标签 javascript r shiny

我正在尝试使用 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/

相关文章:

javascript - Highcharts 在系列数据中有超过 999 个项目?

r - 如何在显示相应列表项时显示代码块?

R Shiny : How to get an reactive data frame updated each time pressing an actionButton without creating a new reactive data frame?

r - 如何以 Shiny 的百分比显示 "numericInput"中的值?

javascript - 使用 Ajax HTML 结构选择特定选项时的 jQuery 事件

javascript - css - 有没有办法让 div 与 h1(多行)在同一第二行?

javascript - 为什么这段代码会报错?

r - 循环具有半类似列名的列

r - 使用 read.table 时监控 R 数据加载进度

r - 添加 UI 元素的一部分作为 introjs() 教程的步骤