Dealing with relative Paths with RMarkdown and RSC

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.

  1. I execute a chunk individually
  2. I knit the Rmd locally
  3. I knit the Rmd within RStudio Connect

I have the understanding that in these three scenarios the corresponding working directory are as follows:

  1. Chunks: Working directory is the current working directory of the session (which is either the project directory or the document directory)
  2. Local knit: Working directory can be specified as being either the document, project or current working directory.
  3. 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?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.