Dealing with a cached chunk that is still taking a long time to execute in R?

Viewed 328

I currently have a 10million row table that I am uploading to R. I understand the uploading process to R make take some time and so as a consequence I decided to store my chunk as chache = TRUE and for good measure I did the following

knitr::opts_chunk$set(cache = TRUE, warning = FALSE, 
                      message = FALSE, cache.lazy = FALSE)

When I re-run my RMarkdown document it is still taking >30minutes to execute the chunk that has the large data frame. Why are my results not being cached so that it does not need to take a long time to execute? I have made no changes to the query and the backend data has not updated as well.

1 Answers

In your question you have chache = TRUE, did you mean cache = TRUE?

You could also have the heavy processing done in it's own R script and call it inside your Rmarkdown with source('rscript.R'). Where caching is set in the .R file

as stated in this link you can cache objects yourself with...

if (file.exists("results.rds")) {
  res <- readRDS("results.rds")
} else {
  res <- compute_it()  # a time-consuming function
  saveRDS(res, "results.rds")
}
Related