I have a project where I put .rmd files in a separate folder called docs. My R Markdown documents looks like this:
---
title: "test"
output: pdf_document
---
## R Markdown
```{r summary}
knitr::opts_knit$set(root.dir = normalizePath("../"))
source('../test.R')
```
My test.R script, sitting in the root folder, looks like this:
source('helloWorld.R')
print("Hello World")
And the helloWorld.R script looks like this:
print("Hello World from separate script")
My two questions are:
Having set the root directory to "..", why do I still need to refer to the test.R using "../"?
Why does the source-within-a-source fail? The above script works fine if I omit the source part of test.R?