Tuesday, February 16, 2016

r - How to set a conditional panel to a selectinput in shiny?

I am trying to add a second inputpanel in my shiny application which content depend on the input of the first inputpanel choice, I tried tout use condional panel with no luck.









TO <- read.csv("~/TO/TO/TO.csv", sep=";")
library(shiny)



shinyUI(fluidPage(



# Application title
titlePanel("dasboard"),



# Sidebar with a slider input for number of bins




sidebarLayout(



sidebarPanel(
selectInput("country", label = h4("Pays"),
choices = levels(as.factor(TO$Pays))),
conditionalPanel(
condition = "input.country == 'Allemagne'",
selectInput("to", label = h4("Tour opérateur"),
choices = levels(as.factor(as.character(TO[as.character(TO$Pays)=="Allemagne",]$TO))))),

conditionalPanel(
condition = "input.country == 'Angleterre'",
selectInput("to", label = h4("Tour Operator"),
choices = levels(as.factor(as.character(TO[as.character(TO$Pays)=="Angleterre",]$TO)))))


...







The solution that I found is to create a conditionalPanel for every value of the first inputPanel But is the second inputPanel output is only correct for the first value.



Does anyone have a solution?

No comments:

Post a Comment