[Rd] Tell whether ./.Rprofile or ~/.Rprofile is being processed?

Henrik Bengtsson henrik.bengtsson at gmail.com
Fri Nov 18 11:08:19 CET 2016


Assume I have one ~/.Rprofile (in my home directory) and one
./.Rprofile (in my current working directory).  In this case, the
latter will have higher priority and will be the script that R uses
during the startup process.

Is there a *generic* way to programmatically from within ./.Rprofile
and ~/.Rprofile to tell what their absolute pathnames are or
equivalently what directories they are located in?  Conceptually
something like:

  path <- directoryOfRprofile()
  message("Running ", file.path(path, ".Rprofile"))
  message(".Rprofile is in the home directory: ", normalizePath(path)
== normalizePath("~"))

I don't want to / cannot manually set the `path` variable.

Since .Rprofile is sourced very early on when R starts up (e.g.
sys.calls() is NULL), I suspect the answer to my question is no, but
maybe someone else can prove me wrong.



More information about the R-devel mailing list