What is a cross-platform method to find the OS temporary directory from within R? I currently use:
dirname(tempdir())
Which did the job both on Ubuntu and Windows from within an interactive R session. However, then it failed when called from inside RApache. In RApache the value of tempdir()
is always /tmp
, so dirname(tempdir())
results in /
, which is obviously wrong. I also tried:
Sys.getenv("TMP")
Sys.getenv("TEMP")
Sys.getenv("TMPDIR")
as suggested by ?"environment variables"
but none of these were set in Ubuntu. It also doesn't seem to be set in any of the files in /etc/R/*
so I don't quite understand how R detects this value.
tempdir()
always return/tmp
is puzzling. Do you have write access to that dir? – JosefinaR_TempDir
to implement some caching. See github.com/jeffreyhorner/rapache – Cantaloupe