Is there a way to make the sliderInput
wait for a couple seconds before it changes its corresponding input$
variable? I have a bar that is controlling a graph that needs to re-render upon the value change. I'm aware of the workaround with a submit button, I'm looking to avoid needing that.
debounce
is made for this, and is simpler. Modifying previous answerer's code:
library(shiny)
library(magrittr)
shinyApp(
server = function(input, output, session) {
d_mean <- reactive({
input$mean
}) %>% debounce(1000)
output$plot <- renderPlot({
x <- rnorm(n=1000, mean=d_mean(), sd=1)
plot(density(x))
})
},
ui = fluidPage(
sliderInput("mean", "Mean:", min = -5, max = 5, value = 0, step= 0.1),
plotOutput("plot")
)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With