I have a bookdown project in R and like to switch to Quarto.
In the bookdown project I have an R script _common.R
(it includes libraries and various settings and helper functions) to run before the rendering of each chapter (separate qmd file).
How can I implement such a script-file in Quarto?
I tried to set in _quarto.yml:
project:
type: book
pre-render: _common.R
But this will only run the script once before the rendering of the complete book, not before each chapter.
Each chapter seems to be rendered in its own environment so all the settings and scripts from _common.R
are not available.
A workaround is to include
```{r echo = FALSE, message=FALSE, warning=FALSE}
source("_common.R")
```
at the top of each .Rmd/.qmd file. Is there a better solution?
Any help appreciated!
.Rprofile
file, so you need either explicitly source the user-level.Rprofile
at the top of your project-level.Rprofile
withsource("~/.Rprofile")
or you will lose your project-level.Rprofile
settings. – Karol