Skip to content
Discussion options

You must be logged in to vote

For R chunks, a way to achieve this is to use code externalisation, i.e. the code chunks are in a separate R file, and all qmd files can refer to them. Example gist

It's also possible to generate the external R file automatically from a qmd document using knitr::purl(), so the process could be automated (file2.qmd referring to chunks from file1.qmd via an automatically generated R file, which could be done as a pre-render step, for instance. When doing this with several files, things could get a bit messy with chunk names (you'd have to keep a good convention to make them unique) and execution order.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@DamonCharlesRoberts
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by DamonCharlesRoberts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants