条件面板中的javascript条件:javascript中%运算符中是否存在R%? [英] conditionalPanel javascript conditions in shiny: is there R %in% operator in javascript?

查看:78
本文介绍了条件面板中的javascript条件:javascript中%运算符中是否存在R%?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用有光泽的包中的 conditionalPanel 函数构建一个闪亮的应用程序。条件应该用 JavaScript 写,但我希望能够使用如下条件(用R编写)

I am trying to build a shiny application using the conditionalPanel function from shiny package. The condition should be written in JavaScript but I would like to be able to use a condition as follows (written in R)

"TP53" %in% unlist(input$ModelVariables)

文档声明:


condition -
将重复计算的JavaScript表达式,以确定面板是否应该是显示。

condition - A JavaScript expression that will be evaluated repeatedly to determine whether the panel should be displayed.

我根本不熟悉 JavaScript 。我已经尝试 input.ModelVariables =='TP53'但是当 input.ModelVariables 有长度时,这不起作用大于1.

I'm not familiar with JavaScript at all. I've tried input.ModelVariables == 'TP53' but this doesn't work when input.ModelVariables has length bigger than 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")
                                                        )


推荐答案

根据这个答案这个条件离子应该工作(它适用于我)

condition =input.ModelVariables.indexOf('TP53')> -1

According to this answer this condition should work (and it works for me) condition = "input.ModelVariables.indexOf('TP53') > -1"

这篇关于条件面板中的javascript条件:javascript中%运算符中是否存在R%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆