Change temporary directory

放肆的年华 提交于 2019-11-26 22:08:34

Create a file called .Renviron in the directory given by Sys.getenv('R_USER') and save it with the line TMP = '<your-desired-tempdir>'.

write("TMP = '<your-desired-tempdir>'", file=file.path(Sys.getenv('R_USER'), '.Renviron'))
Adrian Stoica

In windows, for me what worked is creating a file named Renviron.site and filling it with

TMPDIR=E:/rtemp 
TMP=E:/rtemp 
TEMP=E:/rtemp

Where E:/rtemp was the path to the directory where I wanted the temporary files. So you create a new text file, fill it with the above, and change its name (and extension) to Renviron.site.

Put it inside the R installation directory, in the directory etc (e.g. C:\Program Files\R\R-3.3.2\etc)

Obviously, you need to restart R studio for the change to work! (I use R studio but it should work in R also).

For me, this change allowed me to run a script of species distribution modeling which was creating very large temporary files on the system partition, consuming all the space and killing the process in the end. I have moved the temp files to a usb SSD disk (partition E:), and voila, it worked.

PS - the answer was in one of the links you mentioned.

For Linux, I'm using Ubuntu 18.04.1 LTS. You can try the following line:

write("TMP = YOUR_PATH_VARIABLE", file=file.path('~/.Renviron'))

Explanation: This line will write the TMP variable, which has been assigned to your own temp path, to the '.Renviron' file. And this '.Renviron' file will be created in your home directory. If this doesn't work, restart your R or R studio. The reason is the temporary directory was created before the current R session. So you have to restart another R session to implement this new TEMP_PATH configuration.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!