Skip to content
Prev 43384 / 63424 Next

Best way to locate R executable from within R?

On Tue, May 22, 2012 at 10:47 AM, Dan Tenenbaum <dtenenba at fhcrc.org> wrote:
I don't see how Sys.getenv("R_HOME") would be better than R.home() -
any reasons?

Your reply triggered me to read up on help("R.home"), where I noticed
the passage:

"A character string giving the R home directory or path to a
particular component. Normally the components are all subdirectories
of the R home directory, but this may not be the case in a Unix-like
installation.  [...] The return value for "modules" and on Windows
"bin" is to a sub-architecture-specific location."

So, now I'd say that:

4. Rbin <- file.path(R.home("bin"), "R");

is better than (2).  I'm still not sure whether to use (1) or (4), though.

/Henrik