[Rd] Rgui, Startup, HOME, R_USER, ...

Gabor Grothendieck ggrothendieck at gmail.com
Fri May 5 00:22:37 CEST 2006

Just a few comments:

- although one can use environment variables in Windows applications
(I am referring to applications generally and not just R) its not
the preferred way of doing things.  Its ok to support environment
variables but they should not be relied on as the preferred way
to set configurations though they could be an alternate way.

- HOME is really bad since it can conflict with other applications,
usually ones that have been ported from UNIX

- to find out how startup works I think you will likely have to review the
startup source of code of R.  I once tried to add some lookup of these to
batchfiles (but I ultimately decided to simplify it to the point
where none of them were required) and found that reviewing the R
souce was the quickest way to be sure. That was
a whlie ago though.

On 5/4/06, Henrik Bengtsson (max 7Mb) <hb at stat.berkeley.edu> wrote:
> Hi,
> 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
> path. DS.
> (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.
> M:\>set HOME=
> M:\>Rterm --quiet
> > Sys.getenv("R_USER")
>                                        R_USER
> "C:\\Documents and Settings\\hb\\My Documents"
> M:\>Rterm --quiet
> > Sys.getenv("R_USER")
>                            R_USER
> "C:\\\\Documents and Settings\\hb"
> M:\>Rterm --quiet
> > Sys.getenv("R_USER")
>                                 R_USER
> "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.
> Best,
> /Henrik
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list