R Shiny Make slider value dynamic

后端 未结 4 1515
旧巷少年郎
旧巷少年郎 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:47

    I think you're looking for the updateSliderInput function that allows you to programmatically update a shiny input: http://shiny.rstudio.com/reference/shiny/latest/updateSliderInput.html. There are similar functions for other inputs as well.

     observe({
         x.dataset.selection = input$selection
         if (x.dataset.selection == "raw") {
            x.num.rows = nrow(obatch)
         } else {
            x.num.rows = nrow(eset.spike)
         }
         # Edit: Turns out updateSliderInput can't do this, 
         # but using a numericInput with 
         # updateNumericInput should do the trick.
         updateSliderInput(session, "probes",
           label = paste("Slider label", x.dataset.selection),
           value = c(1,x.num.rows))
     })
    

提交回复
热议问题