As discussed in Pre-Compute Results, Displayr can be sped up by pre-computing results. Where the pre-computed results are large and plentiful, this can slow down the Displayr document. A solution to this is to save pre-computed results in the Displayr Cloud Drive.
Worked Example
This example extends the example in Run Slow Data Queries, Calculations, and Extracts When Users Aren't Using a Document.
The code below extracts stock price data for Microsoft at 1AM New York time and then saves it to the Displayr Cloud Drive.
library(quantmod)
library(reshape2)
data <- new.env()
suppressWarnings(getSymbols("MSFT",
env = data,
from = seq(as.Date(Sys.Date()), length = 2, by = "-5 years")[2],
to = Sys.Date(),
auto.assign = TRUE))
all.data <- data[[ls(data)[1]]]
stock.prices <- data.frame(all.data)
UpdateAt("07-01-2022 1:00:00",
us.format = TRUE,
time.zone = "America/New_York",
units = "days",
frequency = 1,
options = "wakeup")
QSaveData(stock.prices,'msft.stock.price.rds')
"Exporting data to cloud drive every day" # This is a comment so that the calculation is visible
The code below extracts the data from the Displayr Cloud Drive. This approach can be extended to deal with large numbers of files by using for loops and the paste0 function to automatically write file names.
library(flipAPI)
QLoadData('msft.stock.price.rds')
Next