the current working directory inside a notebook chunk is always the directory containing the notebook .Rmd file.
Understood. But if within a notebook we setwd()
to something (either to "the directory containing the notebook .Rmd file" or elsewhere, doesn't matter), this doesn't set the working directory in the console, only in the notebook.
The reverse is also true, setting working directory in the console doesn't change the working directory in the notebook — though this is somewhat explained by the above.
The only way to set working directory both in the console and a notebook seems to be to run the same setwd()
call in both console and notebook.
Why?
Is there any way to streamline this so that the working directory is automatically the same for both notbook and console, once a setwd()
call is made, rather than confusingly having two 'parallel' working directories?
One assumes one is not alone in working from notebooks, but doing the 'dirty work' and quick checks that one has no plan to keep in the console. This working directory behaviour is therefore quite frustrating.