Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define custom tempdir [duplicate]

Tags:

r

I am a user (no admin privileges) of an Ubuntu 12.04.4 machine running R 3.1.

I find I can't start R because Fatal error: cannot create 'R_TempDir. The problem is pretty simple (and already documented here): there's not enough disk space to initialize R temporary directory. Indeed:

df /tmp
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       10320184 10284088         0 100% /

But then I have plenty of space on a different partition (/dev/vdb). How could I tell R to create a temporary folder in a different location?

Since I can't start R, I tried to set in my .Rprofile

.First <- function(){
  ## other stuff
  tempdir("path/to/plenty/of/space/tmp")
  ## other stuff
}

Yet it doesn't work.

Error in tempdir("path/to/plenty/of/space/tmp") : 
  unused argument ("path/to/plenty/of/space/tmp")
Calls: .First -> tempdir
Execution halted

EDIT: Question already answered here. Create a .Rprofile and add this line TMP = '<your-desired-tempdir>'

like image 990
CptNemo Avatar asked Oct 20 '22 05:10

CptNemo


1 Answers

tempdir() only returns the temp directory, and cannot change it, event does not get an argument.

But here is a section of manual of the same function, you can see the complete manual using ?tempdir

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.

Hence you need to set the environmental variable TMPDIR

like image 181
Ali Avatar answered Oct 24 '22 11:10

Ali