R Shiny Make slider value dynamic

后端 未结 4 1484
旧巷少年郎
旧巷少年郎 2021-02-14 09:12

I\'ve got a dropdown selector and a slider scale. I want to render a plot with the drop down selector being the source of data. - I\'ve got this part working

I simply wa

4条回答
  •  被撕碎了的回忆
    2021-02-14 09:46

    As @Edik noted the best way to do this would be to use an update.. type function. It looks like updateSliderInput doesnt allow control of the range so you can try using renderUI on the server side:

    library(shiny)
    runApp(list(
      ui = bootstrapPage(
        numericInput('n', 'Maximum of slider', 100),
        uiOutput("slider"),
        textOutput("test")
      ),
      server = function(input, output) {
        output$slider <- renderUI({
          sliderInput("myslider", "Slider text", 1,
                      max(input$n, isolate(input$myslider)), 21)
        })
    
        output$test <- renderText({input$myslider})
      }
    ))
    

提交回复
热议问题