8 Other topics

8.1 Too much or too slow code

If code runs slowly, the output of code chunks can be cached, so next time the document is rendered the existing cached results can be used. The caching system in R markdown can be activated by setting the chunk option cache: true. The caching system can be tricky to set up for complex projects, and the targets package is a much more robust framework for building reproducible analysis pipelines. See this demonstration project for an example of how to set up targets.

8.2 Paramertised reports

If you need a template for many reports, for example, showing results for a specific location or time period, consider using Paramertised reports which allow you to pass a variable into an R markdown document when it is knitted.