2

I have a shiny dashboard that performs group-bys and ggplot2s from a dataset that is updated every day.

I'm researching a few options for caching:

https://github.com/r-lib/memoise

http://shiny.rstudio-staging.com/articles/plot-caching.html

However, those functions serve if the output remains constant. What if everyday I'm appending a few lines to a dataset. Is there a way to take advantage of caching? Can the cache be updated just to add the new rows of data?

Similar questions were asked here:

caching plots in R/Shiny

Shiny app - Using memoise to cache R values

Example:

Fetching the data every day. This script runs every day and gets new data.
con <- dbConnect(drv = dbDriver(""), 
                 dbname = "db",
                 host = "connection",
                 user = "user",
                 password = "password")
query1 <- dbGetQuery(con,"query1")
query2 <- dbGetQuery(con,"query2")
Maybe a group-by or a join or summarization anything
...
...
...
Finally your have your final dataset.
final <- rbind(query1, query2)
s3saveRDS(x = final, 
      object = paste0("data", ".rds"),
      bucket = "bucketname") 

In your shiny application you use it:

final <- s3readRDS(object = "data.rds",
                 bucket = "bucketname")

How can I benefit from caching if my data has new rows every day?

dank
  • 303
  • 4
  • 20
  • 1
    Could you write a separate R script that runs daily to pull the data, process it, then place it somewhere that Shiny could access it? Would that be helpful or not in scope? – Jacqueline Nolis Apr 16 '19 at 22:41
  • @JacquelineNolis Hopefully the edit helps. It's kind of a general question – dank Apr 17 '19 at 00:31

0 Answers0