更改rmarkDown中的WD
我的R MARKDOWN脚本运行良好,直到我不得不从RmarkDown文件中访问另一个WD的文档。我试图更改WD。但这没有接受。 在我的R Markdown文档中,我可能会从不同文件夹访问文档。如何在不将文件交配到R Markdown文件夹的情况下更加灵活? (那会浪费空间!)
这是正确的命令吗?
knitr::opts_knit$set(root.dir = "C:/Users/Nadine/OneDrive/ZID_Kurse/Einführung/Kursmaterial")
我需要把它放在文档的开头吗??? 它只是用setWD()命令在块上停止。
干杯, 纳丁
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能不需要更改工作目录;只需说明在哪里可以找到相对于项目工作目录的文件即可。您可以使用文件系统上文件的绝对路径,例如
list.files(“ c:/projects/entern_project/data/”)
,也可以尝试使用相对路径通过父目录导航到文件。例如
list.files(“ ../另一_Project/data/”)
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/")