XR SC XR SC - 1 month ago 21
R Question

How to specify global chunk option in a rmarkdown website?

It is possible to create a website with several rmarkdown files. For each rmarkdown file, we can specify some global options like:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message=FALSE, warning=FALSE)
```


If I want to apply all these options to all rmd files, I can put the same code in each file.

I would like to know if it is possible to put this code somewhere so that it can be shared to every rmd files. In fact, sometimes, I want to make some change (for example set echo = TRUE), and I want to do it once for the entire website.

Answer

You can include a child document

```{r, child="_setup.Rmd"}
```

at the beginning of each rmd file.