Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does running R.exe create temporary files?

Tags:

r

I'm wondering

  • does launching R.exe on windows create temporary files and
  • does interpreting something like x <- 5 write to those temporary files?

If temporary files are created where are they stored and what happens if I launch several instances of R.exe? Will they share and overwrite each others temporary files?

like image 371
hidarikani Avatar asked Dec 20 '22 10:12

hidarikani


1 Answers

Each instance of R gets its own temporary directory. You can see that pretty easily below the default temporary directory on your system (eg /tmp for me; on Windows I usually set TEMPDIR and TMPDIR to C:\TMP and find them there; I forget where they go otherwise). But when you invoke tempfile() or tempdir() you can infer the path:

R> tempfile()
[1] "/tmp/RtmpDVDtmj/file6a27612c4c83"
R> 

So the R session in which I typed this uses /tmp/RtmpDVDtmj/.

The directory name is randomized and safe from other R instances running at the same time.

At exit of R, the directory is purged.

And no, the simple assignment x <- 5 will not involve a temporary file.

like image 188
Dirk Eddelbuettel Avatar answered Jan 22 '23 10:01

Dirk Eddelbuettel