yes! That's my question.
Let's assume I have a main .Rmd document
---
output:
pdf_document: default
html_document: default
---
#```{r, child=c('child1.Rmd')}
#```
and a child document called child1.Rmd .
plot(x)
I want to provide objects generated in one file, let's call it setup.Rmd to each child .Rmd script such that each child can be standalone with the setup.Rmd being
x <- rnorm(100)
a possible other child2.Rmd could be
plot(x, type = "p")
I'd like to include the setup.Rmd to a child with
#```{r, child=c('setup.Rmd')}
#```
If I could get the name of the current script the child could be
#```
# filename <- ???
#```
#```{r, if (filename) child=c('setup.Rmd')}
#```
If it would run within RStudio you could extract the filename with rstudioapi::getActiveDocumentContext()$path
But there must be another solution.