Setting work directory in knitr using opts_chunk$set(root.dir = …) doesn't work

后端 未结 5 1074
北荒
北荒 2020-12-05 17:39

My R project is structured like a package with directories /R, /vignettes, /data etc. In one of my Rmd docs in /vignettes

5条回答
  •  无人及你
    2020-12-05 18:07

    As Yihui has pointed out in his answer the mistake was simply that I used opts_chunk$set() instead of opts_knit$set().

    However it might be worth noting that the change of the working directory affects not the current but only the next chunk. So e. g. if you want to load data relative to the new working directory do that in the following chunk.

提交回复
热议问题