gpt4 book ai didi

r - 在 R 中更改临时目录

转载 作者:行者123 更新时间:2023-12-04 12:26:32 40 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Change temporary directory

(4 个回答)


3年前关闭。




我正在使用 Windows 虚拟机,并且在其上安装了 R 和 RStudio,我正在尝试更改 R 写入临时文件的目录。

当我启动 R 时,我尝试更改临时目录,然后关闭 R。当我重新启动 R 并尝试时 tempdir()它仍然显示旧目录,好像什么也没发生。但是,如果在尝试更改 R 中的临时目录后我启动 RStudio 而不是重新启动 R,当我尝试时 tempdir()在 RStudio 中,它显示了我在 R 中设置的新/更新目录。这怎么可能?怎么了?为什么只有 RStudio 响应我更改临时目录而不响应 R,即使我正在更改目录?

最佳答案

你究竟是如何设置临时目录的? ?tempdir 中的 R 文档说这个:

By default, tmpdir will be the directory given by tempdir(). This will be a subdirectory of the per-session temporary directory found by the following rule when the R session is started. The environment variables TMPDIR, TMP and TEMP are checked in turn and the first found which points to a writable directory is used: if none succeeds ‘/tmp’ is used. The path should not contain spaces. Note that setting any of these environment variables in the R session has no effect on tempdir(): the per-session temporary directory is created before the interpreter is started.



据推测,如果您有 TMPDIR环境变量集,R(以及 RStudio)应该做正确的事情。请注意,您必须在 R/RStudio 启动之前进行设置;您很可能可以通过将其设置在 ~/.Renviron 内来实现此目的。或 ~/.Rprofile .

另见: Change temporary directory

关于r - 在 R 中更改临时目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38364431/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com