我想要在mainPanel中更新滑塊的值。以下是我的代碼 -動作按鈕不會更新sliderinput值
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)
因此,當我選擇區域作爲北,然後按提交,它顯示我正確的值。但是,當我選擇Zone作爲South時,滑塊會更改基本條件面板,但表格中的值仍然爲North。
我該如何解決這個問題?
感謝
我,因爲它是在區域的選擇我的應用程序基礎上其他地方正在使用無法在有條件面板更改名稱。 – user1463242
問題解決。我使用'observeEvent'來更改各個區域選擇的滑塊值。 – user1463242
您能否將上述示例的解決方案代碼作爲答案發布? – Wietze314