r - shiny conditional panel not updating -
i have issue conditional panel. show in sidebarpanel either daterange or sliderinput depending on selected choice in radiobutton, in sidebarpanel.
if try run below example fail following error message:
error : formal argument "condition" matched multiple actual arguments
if comment out of 2 conditions can see example
variable has value a
or b
depending on options chosen.
i'm pretty sure i'm missing something, cannot figure out what. did around , couldn't find helpful.
library(shiny) # server --------------------------------------------- server = shinyserver(function(input, output){ output$debug <- renderprint({ input$example }) }) # ui ------------------------------------------------- ui = { fluidpage( sidebarpanel( radiobuttons('example', 'select examples: ', choices = c('a', 'b'), selected = 'a'), conditionalpanel( condition = "input.example == 'a'", daterangeinput('date', 'select date range:', start = sys.date() - 7, end = sys.date(), min = '2012-04-01', max = sys.date() ) , condition = "input.example == 'b'", sliderinput('date', 'slide date range:', min = 1, max = 90, value = 14, step = 1) ) ), mainpanel(verbatimtextoutput("debug") ) )} # app ------------------------------------------------ shinyapp(ui = ui, server = server)
thanks
you need specify 2 conditionalpanel objects, 1 each condition.
library(shiny) # server --------------------------------------------- server = shinyserver(function(input, output){ output$debug <- renderprint({ input$example }) }) # ui ------------------------------------------------- ui = { fluidpage( sidebarpanel( radiobuttons('example', 'select examples: ', choices = c('a', 'b'), selected = 'a'), conditionalpanel( condition = "input.example == 'a'", daterangeinput('date', 'select date range:', start = sys.date() - 7, end = sys.date(), min = '2012-04-01', max = sys.date() ) ), conditionalpanel( condition = "input.example = 'b'", sliderinput('date', 'slide date range:', min = 1, max = 90, value = 14, step = 1) ) ), mainpanel(verbatimtextoutput("debug") ) )} # app ------------------------------------------------ shinyapp(ui = ui, server = server)
Comments
Post a Comment