我有一个闪亮的仪表板,可以从每天更新的数据集中执行分组依据和ggplot2s。
我正在研究一些缓存选项:
https://github.com/r-lib/memoise
http://shiny.rstudio-staging.com/articles/plot-caching.html
但是,如果输出保持恒定,则这些功能起作用。如果每天我要向数据集添加几行怎么办?有没有办法利用缓存?可以仅更新缓存以添加新的数据行吗?
在这里问了类似的问题:
Shiny app - Using memoise to cache R values
示例:
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")
在闪亮的应用程序中使用它:
final <- s3readRDS(object = "data.rds",
bucket = "bucketname")
如果我的数据每天都有新行,如何从缓存中受益?