I'm trying to figure out a way of dealing with relative paths (when importing data) which consistently works in all of the the following scenarios.
- I execute a chunk individually
- I knit the Rmd locally
- I knit the Rmd within RStudio Connect
I have the understanding that in these three scenarios the corresponding working directory are as follows:
- Chunks: Working directory is the current working directory of the session (which is either the project directory or the document directory)
- Local knit: Working directory can be specified as being either the document, project or current working directory.
- RSC knit: Working directory is always the document directory
As I'm writing this, I realise that the best option would probably be to specify the working directory for local knitting as the "document directory" and set the working directory (
setwd()) accordingly before executing individual chunks. Is this correct? Or are there better options?