R 实时更新ui值-闪亮

R 实时更新ui值-闪亮,r,shiny,R,Shiny,从ui.r,我想将第二个sliderInput的最大值设置为第一个sliderInput的当前值。我该怎么做 sliderInput("blockSize", "block size", min = 1, max = 12, value = 8, step = 1) #max should be the current value of blockSize instead of 12 sliderInput("offset", "offset", min = 1, max = 12 , val

ui.r
,我想将第二个
sliderInput
的最大值设置为第一个
sliderInput
的当前值。我该怎么做

sliderInput("blockSize", "block size", min = 1, max = 12, value = 8, step = 1)

#max should be the current value of blockSize instead of 12
sliderInput("offset", "offset", min = 1, max = 12 , value = 1, step = 1)

根据第一个滑块输入更新第二个滑块输入的示例代码。关键是

observeEvent(input$bins, {
    updateSliderInput(session, "bins2", max=input$bins)
})
完整代码

library(shiny)

ui <- shinyUI(fluidPage(

   titlePanel("Old Faithful Geyser Data"),

   sidebarLayout(
      sidebarPanel(
         sliderInput("bins",
                     "Number of bins:",
                     min = 1,
                     max = 50,
                     value = 30),
         sliderInput("bins2",
                     "Number of bins:",
                     min = 1,
                     max = 50,
                     value = 30)
      ),

      mainPanel(
         plotOutput("distPlot")
      )
   )
))

server <- shinyServer(function(input, output, session) {

    observeEvent(input$bins, {
        updateSliderInput(session, "bins2", max=input$bins)
    })

   output$distPlot <- renderPlot({
      x    <- faithful[, 2] 
      bins <- seq(min(x), max(x), length.out = input$bins + 1)

      hist(x, breaks = bins, col = 'darkgray', border = 'white')
   })
})

shinyApp(ui = ui, server = server)
库(闪亮)

ui在服务器端使用
observeEvent
updateSliderInput
根据第一个onethanks的值动态更新第二个滑块,是否有办法在用户端进行此更新?我希望更新速度快。更新速度非常快。如果要在拖动第一个滑块时更改第二个滑块,请参见以获取解决方案。除非修改滑块的原始javascript对象(正如我在链接中提到的,Shiny使用
Ion.RangeSloider
作为底层实现),否则在ui.R中无法完全做到这一点。