Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Changing WD in RMarkdown

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Cheers,
Nadine

>Solution :

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/")

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading