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)
the documenatation states:
condition - A JavaScript expression that will be evaluated repeatedly to determine whether the panel should be displayed.
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.
My sidebarPanel
fragment with conditionalPanel
is below
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")
)
According to this answer this condition should work (and it works for me)
condition = "input.ModelVariables.indexOf('TP53') > -1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With