Created
November 9, 2018 16:32
-
-
Save jcheng5/1f09a0939ae45fd36f286a158bcb0dfb to your computer and use it in GitHub Desktop.
Simple Shiny app, with and without plot caching
This file contains hidden or 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(ggplot2) | |
library(shiny) | |
ui <- fluidPage( | |
varSelectInput("color_by", "Color by:", diamonds, selected = "cut"), | |
plotOutput("plot") | |
) | |
server <- function(input, output, session) { | |
output$plot <- renderPlot({ | |
ggplot(diamonds, aes(carat, price, color = !!input$color_by)) + | |
geom_point() | |
}) | |
} | |
shinyApp(ui, server) |
This file contains hidden or 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(ggplot2) | |
library(shiny) | |
shinyOptions(cache = diskCache("plot_cache")) | |
ui <- fluidPage( | |
varSelectInput("color_by", "Color by:", diamonds, selected = "cut"), | |
plotOutput("plot") | |
) | |
server <- function(input, output, session) { | |
output$plot <- renderCachedPlot({ | |
ggplot(diamonds, aes(carat, price, color = !!input$color_by)) + geom_point() | |
}, cacheKeyExpr = { input$color_by }) | |
} | |
shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment