"is.element" Javascript condition in conditionalPanel

559 views
Skip to first unread message

Stéphane Laurent

unread,
Oct 22, 2013, 3:35:19 PM10/22/13
to shiny-...@googlegroups.com
Hello,

 In a conditionalPanel in ui.R, I'd like to have a condition such as :

conditionalPanel(condition= "input$tabset %in% c('A','B')", ...

but here my condition input$tabset %in% c('A','B') is written in R syntax. Is it possible to write it as a Javascript expression ? 

(otherwise I know I can use a dynamic UI, but I'd like not to use one).

Yihui Xie

unread,
Oct 22, 2013, 3:41:27 PM10/22/13
to Stéphane Laurent, shiny-...@googlegroups.com
There is a .indexOf() method for JS Arrays, e.g.

x=[0,1,3,9,5]
// [0, 1, 3, 9, 5]
x.indexOf(9)
// 3

If the element is not found, it returns -1.

Regards,
Yihui
--
Yihui Xie <yi...@rstudio.com>
Web: http://yihui.name

Stéphane Laurent

unread,
Oct 22, 2013, 3:53:36 PM10/22/13
to shiny-...@googlegroups.com, Stéphane Laurent
You are right, the following works:

    conditionalPanel(condition= "['A','B'].indexOf(input.tabset) != -1", ...

Thank you very much !
Reply all
Reply to author
Forward
0 new messages