knitr::read_chunks and knitr::purl for other languages #9112
Replies: 3 comments 18 replies
-
I would like to have this feature, too. My use-case are What I ended up doing is to implement a conversion from Jupyter notebook to Matlab script in Matlab, called from a code cell with But such a conversion could be implemented in Quarto itself, activated e.g. via a YAML header format:
html: default
script: default and offered for download as an "other format". Somewhat related: #7411. |
Beta Was this translation helpful? Give feedback.
-
For reference: |
Beta Was this translation helpful? Give feedback.
-
quarto R package will now have an experimental This is a wrapper around As of 07/2025, this is in dev version at https://github.com/quarto-dev/quarto-r It can be installed easily using Github or r-universe build: https://quarto-dev.r-universe.dev/quarto See vignette: https://quarto-dev.github.io/quarto-r/articles/r-scripts.html |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I'm a big fan of knitr's code externalisation: it lets me tinker with the code in a self-contained document, reuse it in other files (e.g.
source('funs.R')
) etc. while focusing more on the text/narrative in the Rmd/qmd file, but still benefit from the reproducibility of literate programming (namely: the code is the actual code, and all artefacts have resulted from it).Unfortunately, I believe this only exists for the knitr+R combination, not for other languages or engines?
As a workaround, I've resorted to a reverse strategy, where all the code is in a qmd file, and I use
knitr::purl
to extract it to a standalone source file.Note the R code at the end is not in a chunk, lest it be included in the julia script (and would cause errors). It's a bit awkward, I think it'd be nice if quarto had such an option to "dump" all code into a script at the user's request? (and ideally this script could be listed as "other formats" in a quarto webpage). (So I guess this is 3 feature requests into one)
Beta Was this translation helpful? Give feedback.
All reactions