R Shiny Make slider value dynamic

后端 未结 4 1947
不知归路
不知归路 2021-02-14 09:01

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 10:01

    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})
      }
    ))
    

提交回复
热议问题