Using the Knit button from RStudio works beautifully for me when working with simple files, automatically generates the Rmd files and then the PDF. Now I am working on a larger project where I've split the directories to
MainProjectDir/
MainProjectDir/Code/
MainProjectDir/DataRaw/
MainProjectDir/DataWork/
getwd() gives me the MainProjectDir path. The .r files in the Code directory call each other and also load and save data from/to the Data directories by using relative paths from the MainProjectDir path.
Now, when using the Knit button for a .r file in the Code directory I get connection error:
Error in file(filename, "r", encoding=encoding) : cannot open the connection
After reading a few responses here and looking at Yihui's page I tried setting the root.dir option in the knitr package with
knitr::opts_knit$set(root.dir="..")
in the console before pressing the Knit button in RStudio. Still I get same error. Tried also an absolute path version of the path. What am I doing wrong?