issues ssetting working directory

How do you debug this error

The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the working directory for notebook chunks

https://philmikejones.me/tutorials/2015-05-20-set-root-directory-knitr/

Knitr, by default, looks in the same directory as your .Rmd file to find any files you need to draw in, like data sets or script files. If you keep your data files and scripts in separate folders (and you should) you need to configure knitr.

You cannot use setwd() with knitr, so the canonical way to do this is to include an initial code chunk:

```{r setup, include=FALSE, echo=FALSE}
require("knitr")
opts_knit$set(root.dir = "~/path/to/folder/")```

This creates an R chunk called setup which isn’t included in the knitted file. It loads the knitr package and sets root.dir to your project folder. Knitr will now look for all files from this root folder rather than the folder it is stored in.

1 Like

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