更改rmarkDown中的WD

发布于 2025-01-24 16:18:44 字数 340 浏览 2 评论 0原文

我的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的黑色迷你裙 2025-01-31 16:18:44

您可能不需要更改工作目录;只需说明在哪里可以找到相对于项目工作目录的文件即可。您可以使用文件系统上文件的绝对路径,例如

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文