Home > Back-end >  How to knit Rmarkdown files without the need to run the codes
How to knit Rmarkdown files without the need to run the codes

Time:07-15

I am not sure how to express my question in a well-understood manner. Anyway, my problem is that when I knit the Rmarkdown file, R rerun everything in the file (import data, run models, etc.), which takes a lot of time. Is there a way I can have the output of the models, data frames, graphs, or tables and save that as objects then use these objects as they are without running the process that generated them again during knitting?

Thanks

CodePudding user response:

I believe that your best option is to use the cache capabilities in RMarkdown: {r cache=TRUE}.

Se more here: https://bookdown.org/yihui/rmarkdown-cookbook/cache.html

CodePudding user response:

I find it's effective to do the data preparation and model fitting in a separate .Rmd or .R file and save the resulting data frames and model objects with save.

The notebook I create with figures and tables simply loads the objects in the first chunk with load. That way I can easily iterate on the visualizations and tables without having to re-run the models every time.

CodePudding user response:

Take a look at R Notebooks:

https://bookdown.org/yihui/rmarkdown/notebook.html

Notebooks are just like markdown, but with exactly the feature you are looking for.

  • Related