0

My R Markdown script was running well until I had to access documents from another WD than my RMarkdown-file. I tried to change the WD. But it doesn't take it. I might access documents from different folder during my R Markdown Document. How can I be more flexible without coping my files into R Markdown folders? (that would be wasting space!)

Is this the right command?

knitr::opts_knit$set(root.dir = "C:/Users/Nadine/OneDrive/ZID_Kurse/Einführung/Kursmaterial")

And do I need to put it in the beginning of the document??? It just halts at the chunk with setWD() command.

Cheers, Nadine

Nadiine El Nino
  • 339
  • 1
  • 6

1 Answers1

0

You probably do not need to change the working directory; just explain where to find the files relative to the project working directory. You can use an absolute path to the files on the filesystem, e.g.

list.files("C:/projects/another_project/data/")

Or you may try to use relative paths to navigate to files through the parent directory. e.g.

list.files("../another_project/data/")

Sef
  • 240
  • 1
  • 5
  • Thank you. Yes it just came to my mind that this is the best solution. To use the absolute file path. This is very transparent. – Nadiine El Nino Apr 28 '22 at 09:49