r - Action Button does not update sliderinput values -
i want update values of table in mainpanel basis value of sliders. below code-
library(shiny) ui <- shinyui(fluidpage( sidebarpanel( selectinput(inputid="zone", label="choose forecasting zone:",choices = list("north", "south")), wellpanel( conditionalpanel( condition = "input.zone == 'north'", sliderinput("num1", "no of sellers:",0,3500,value = c(2877,3277),step=1), sliderinput("num3", "activation percentage:",0,1,value = c(0.25,0.32),step=0.01), sliderinput("num5", "case size:",0,200000,value = c(60000,75000),step=1), sliderinput("num7", "case rate:",0,4,value = c(1.34,1.45),step=0.01) ), conditionalpanel( condition = "input.zone == 'south'", sliderinput("num1", "no of sellers:",0,3500,value = c(1008,1148),step=1), sliderinput("num3", "activation percentage:",0,1,value = c(0.26,0.32),step=0.01), sliderinput("num5", "case size:",0,200000,value = c(70000,80000),step=1), sliderinput("num7", "case rate:",0,4,value = c(1.15,1.22),step=0.01) ), actionbutton("sumbit", "submit") ) ), mainpanel("",htmloutput("valuetable")) ) ) server <- function(input, output, session) { aab <- reactive({ input$sumbit isolate({ a1<-cbind(input$num1[1],input$num1[2]) a2<-cbind(input$num3[1],input$num3[2]) a3<-cbind(input$num5[1],input$num5[2]) a4<-cbind(input$num7[1],input$num7[2]) aa<-cbind(input$zone,a1,a2,a3,a4) aa }) }) output$valuetable <- renderui({ input$sumbit isolate({ aa<-aab() aa<-as.data.frame(aa) output$aa1 <- renderdatatable(aa,options = list(paging = false,searching = false,info=false,autowidth=true)) datatableoutput("aa1") }) }) } shinyapp(ui, server)
so when select zone north , press submit, shows me right values. when select zone south, sliders change basis conditional panels values in table still north.
how can fix this?
thanks
if press submit button values in table updated, whether in north or south. aab()
reactive on submit
button , not on sliders. loading app , moving sliders in zone north not update data, when not press submit.
you isolated other controls, don't activate reactive part when changing sliders.
furthermore have used identical names both conditional panels (num1 num3 num5
, num7
). should rename south inputs, , conditionally create results in aab()
.
Comments
Post a Comment