[Rd] Rgui, Startup, HOME, R_USER, ...
Henrik Bengtsson (max 7Mb)
hb at stat.berkeley.edu
Thu May 4 23:49:58 CEST 2006
Main objective: Let Rgui find my ~/.Rprofile and ~/.Renviron files,
where ~ is equal to getwd("~").
I have few comments/questions:
(A) On my WinXP Pro installation, the system environment variable
'HOME' is not availble to R, e.g. Sys.getenv("HOME") is empty. I
believe this is default case (correct me if I'm wrong). However, if I
set the "Start in:" to %HOME% in the Properties for the Rgui.exe file,
the working directory is indeed set to getwd("~"), so 'HOME' is
available for the startup of R. Excuse me for my lack of
understanding WinXP, but why is this? What sysenv variables are
available to the R process? PS. I know I can add HOME=<path> in the
Rgui.exe properties, however I'm interested in the default lookup
(B) With the default "Start in:" value of "C:\Program
Files\R\R-2.3.0pat", the ~/My Documents/.Rprofile is called. I tried
to understand why exactly this path. Reading the R FAQ for Windows,
it says that 'R_USER' is used as the default value for the home
directory. Where/when is this set, and how? I don't set it myself.
It looks like it is set equal to 'HOME' and if that is not set, the to
the default %HOMEDRIVE%\%HOMEPATH%\My Documents\, e.g.
"C:\\Documents and Settings\\hb\\My Documents"
"C:\\\\Documents and Settings\\hb"
"C:\\\\Documents and Settings\\hb\\foo"
>From the above I found out that I should put .Rprofile etc in ~/My
Documents/ for Rgui to find it by default. Is this behavior
documented somewhere and why this specific directory? For parallelism
to Unix etc, it would be more natural to have ~/.Rprofile search for
by default, but that is not the case (unless I set HOME).
(C) Is it possible to set HOME globally to %HOMEDRIVE%\%HOMEPATH% once
and for all without editing the Rgui.exe properties?
(D) Depending a little bit how and when R_USER is set, could I suggest
the the default "Start in:" path for Rgui.exe is changed from the
installation directory to %HOME% instead? This is more user friendly,
especially to beginners, I think.
More information about the R-devel