Home > Mobile >  Setting Working Directory using knitr::opts_knit
Setting Working Directory using knitr::opts_knit

Time:12-21

I am trying to use the code below to change the working directory in R markdown (using the R setup chunk). However, this doesn't seem to be working. The output from getwd() after running this chunk remains as the directory containing the R script. I've never had this issue before; any ideas of where I'm going wrong? Thank you!

```{r setup}
library(foreach)
library(stringr)
library(rmarkdown)
library(knitr)

knitr::opts_knit$set(root.dir = normalizePath('/Users/chantal/Documents/PhD/Projects/'))
getwd()
```

CodePudding user response:

Based on enter image description here

  • Related