Skip to content

Instantly share code, notes, and snippets.

@mgei
Created November 4, 2019 20:12
Show Gist options
  • Save mgei/31cf59db16cc085e2814c6c8518c234d to your computer and use it in GitHub Desktop.
Save mgei/31cf59db16cc085e2814c6c8518c234d to your computer and use it in GitHub Desktop.
library(shiny)
library(tidyverse)
# data <- readRDS("persistent_data/data.RDS")
data <- as_tibble(mtcars) %>% head()
ui <- fluidPage(
tableOutput("mytable"),
actionButton("go", "filter it"),
actionButton("save", "save it")
)
server <- function(input, output, session) {
appdata <- reactiveVal(value = data)
observeEvent(input$go, {
new <- appdata() %>%
filter(cyl == 6)
appdata(new)
})
output$mytable <- renderTable({ appdata() })
observeEvent(input$save, {
# appdata() %>% saveRDS("persistent_data/data.RDS")
})
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment