Created
September 14, 2019 13:43
-
-
Save dokato/7c0e7717b732d1aa6574687ff6125f64 to your computer and use it in GitHub Desktop.
delayed checkbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(magrittr) | |
library(ggplot2) | |
ui <- fluidPage( | |
checkboxGroupInput("checkbox", "Variables to show:", | |
c("psavert", "uempmed", "unemploy")), | |
plotOutput("plot") | |
) | |
server <- function(input, output, session) { | |
checkbox <- reactive({ | |
input$checkbox | |
}) | |
checkbox_delayed <- checkbox %>% debounce(1000) | |
output$plot <- renderPlot({ | |
p <- ggplot(economics, aes(x = date)) | |
lapply(checkbox_delayed(), function(z) {p <<- p + geom_line(aes_string(y = z)) }) | |
p | |
}) | |
} | |
shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment