From henrik.bengtsson at gmail.com  Fri Nov 18 11:08:19 2016
From: henrik.bengtsson at gmail.com (Henrik Bengtsson)
Date: Fri, 18 Nov 2016 11:08:19 +0100
Subject: [Rd] Tell whether ./.Rprofile or ~/.Rprofile is being processed?
Message-ID: <CAFDcVCSFPAyZAZrfKqzETc416rg2trw1K2jw-Uzt9pqqmZpQ+g@mail.gmail.com>

Hi.

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.

Thanks,

Henrik



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