How to organize creation of multiple very similar reports for different audiences

Hello everyone!

I have the following problem:
We evaluate models that we generate using an RMD template that produces different plots and tables. We will individualize and comment these elements and the results for every model, to highlight the key differences and insights. This often happens after presentations and discussions or during code review, improving and finetuning the report over time.

But we do also create a slimmed down version of the report for external stakeholders, which does not include all of the elements from the report that we use internally.

The problem:
Now we do have those two reports and they come out of sync very fast. After feedback some plot gets changed, some comments added here or there and the two reports do not show quite the same results anymore even where they should. Currently I use a diffchecker to see where they differ and try to get them back in sync, but that is really not a useful way how to do it.

We were trying to come up with solutions for this:

  1. Setting some chunks to not evaluate for the external report, but how do we keep the comments and plain text to show up?

  2. Creating two documents that are knitted together into one. Like always knitting the slimmer report and adding on extra chunks and plain text in a separate RMD that get knitted together somehow (maybe using bookdown)

But I am sure that we are not the first and only people encountering this problem and I wanted to ask if anyone has found a good approach for problems like this.

Thanks for any insights or pointers towards materials!

Further information:
We use Rstudio, sync our code through github and do most of the data processing in SQL chunks for this report.

I can only offer a theoretical framework, based on a functional analysis of the problem.

The database with its stored procedures is accessed through some function f to create a primary object x that is further processed through R chunks in Rmd to produce two reports, y and y', where y' is a subset of y. Let f' be the logic that produces y and f'' the logic to produces the reduced report.

The reason that y and y' become out-of-sync is that f' and f'' become out of sync. This may because the two functions are operating on different outputs of f (the function that pulls the objects on which the Rmd chunks operate). This can be prevented by making the argument to f'' solely dependent on the value of f'.

That implies that

  1. The function f'' should be called and the associated Rmd regenerated every time that f' is called and the associated Rmd is modified.
  2. The logic for f' should be contained in the first chunk, either directly or through a source() statement and the subsequent chunks be used solely for rendering the objects created by the primary logic.

In terms of implementation, the key would be to create the subset report only on demand, requiring running the detailed report.

Thank you for your feedback. It did help me to realize that there is probably no perfect solution.

I decided to set up the Rmd in a way that not all chunks are run every time. Following the advice found here: r - Conditionally display block of markdown text using knitr - Stack Overflow

I now set a variable at the top of the report for internal / external report and only the corresponding chunks are knitted and included in the HTML then.

I will see how this works in practice.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.