I am having difficulty coming to grips with Appendix B.2 of the
otherwise very useful "An Introduction to R" and the related help file
for Startup. I am running RGui 1.6.0 on a Windows 2000 machine from the
default installation. How the concepts discussed in B.2 and the Startup
help file relate to what I see on my machine is something of a mystery.
I quote from the Startup file:
"In R, the startup mechanism is as follows.
Unless --no-environ was given, R searches for user and site files to
process for setting environment variables. The name of the site file is
the one pointed to by the environment variable R\_ENVIRON; if this is
unset, `$R_HOME/etc/Renviron.site' is used. The user files searched for
are `.Renviron' in the current or in the user's home directory (in that
order). See Details for how the files are read."
How can I tell if "--no-environ" was given? I cannot find either
Renviron.site or .Renviron on my system.
Then, Startup continues:
"Then R searches for the site-wide startup profile unless the command
line option --no-site-file was given. The name of this file is taken
from the value of the R\_PROFILE environment variable. If this variable
is unset, the default is `$R_HOME/etc/Rprofile.site'. This code is
loaded into package base."
Can I tell if "--no-site-file" was given? I don't find any object named
Rprofile.site on my machine.
Returning to Startup:
"Then, unless --no-init-file was given, R searches for a file called
`.Rprofile' in the current directory or in the user's home directory (in
that order) and sources it into the user workspace."
Was "--no.init.file" given in the default startup? I cannot find a file
.Rprofile anywhere.
Back to Startup:
"It then loads a saved image of the user workspace from `.RData' if
there
is one (unless --no-restore-data was specified, or --no-restore)."
Since R opens with a saved workspace, I'd guess "--no-restore-data" was
not specified.
"Finally, if a function .First exists, it is executed as .First()."
I located such a function in a Rprofile file. It appears to load the
ctest package.
"The functions .First and .Last can be defined in the appropriate
startup
profiles or reside in `.RData'."
What or where are these appropriate startup profiles? I located a
second Rprofile file in the \etc folder, but when I added a .First
function there it seemed to override the other .First function. Is that
intentional?
Later in the Startup help:
"Lines in a site or user environment file should be either comment lines
starting with #, or lines of the form name=value. The latter sets the
environmental variable name to value, overriding an existing value. If
value is of the form ${foo-bar}, the value is that of the environmental
variable foo if that exists and is set to a non-empty value, otherwise
bar. This construction can be nested, so bar can be of the same form (as
in ${foo-${bar-blah}})."
Are environment files the same as profile files?
Finally, towards the bottom of the Startup help:
"Examples
## Some examples with a Unix flavour
# ~/.Renviron
R_LIBS=~/R/library
PAGER=/usr/local/bin/less
# .Rprofile
options(width=65, digits=5)
options(show.signif.stars=FALSE)
ps.options(horizontal=FALSE)
set.seed(1234)
.First <- function() cat("\n Welcome to R!\n\n")
.Last <- function() cat("\n Goodbye!\n\n")
## if .Renviron contains
FOOBAR="coo\bar"doh\ex"abc\"def'"
## then we get
cat(Sys.getenv("FOOBAR"), "\n")
coo\bardoh\exabc"def' "
What would some Windows examples look like?
I love R, and I would really like to learn something more about how it
is being customized for me and how I can (if I should) try to customize
it myself.
Clifford E. Lunneborg
Emeritus Professor, Statistics and Psychology
University of Washington, Seattle
Email: cliff at ms.washington.edu
Phone: 206 364 2013
Fax: 206 366 1078
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Unfortunately the Startup.Rd file was written for Unix, and in 1.6.0 is
not accurate for other platforms. It has been altered in R-patched.
On Thu, 17 Oct 2002, Cliff Lunneborg wrote:
I am having difficulty coming to grips with Appendix B.2 of the
otherwise very useful "An Introduction to R" and the related help file
for Startup. I am running RGui 1.6.0 on a Windows 2000 machine from the
default installation. How the concepts discussed in B.2 and the Startup
help file relate to what I see on my machine is something of a mystery.
I quote from the Startup file:
"In R, the startup mechanism is as follows.
Unless --no-environ was given, R searches for user and site files to
process for setting environment variables. The name of the site file is
the one pointed to by the environment variable R\_ENVIRON; if this is
unset, `$R_HOME/etc/Renviron.site' is used. The user files searched for
are `.Renviron' in the current or in the user's home directory (in that
order). See Details for how the files are read."
How can I tell if "--no-environ" was given? I cannot find either
Renviron.site or .Renviron on my system.
The files need not exist, and are only used if they do exist. *You* gave
the command line so you specified --no-environ or not.
$R_HOME/etc/Renviron.site is only used on Unix: that was a documentation
error.
Then, Startup continues:
"Then R searches for the site-wide startup profile unless the command
line option --no-site-file was given. The name of this file is taken
from the value of the R\_PROFILE environment variable. If this variable
is unset, the default is `$R_HOME/etc/Rprofile.site'. This code is
loaded into package base."
Can I tell if "--no-site-file" was given? I don't find any object named
Rprofile.site on my machine.
Same answer. Rprofile.site is intended for R code to be run initially for
all users and all usages of that R installation, e.g. to load local
package.
Returning to Startup:
"Then, unless --no-init-file was given, R searches for a file called
`.Rprofile' in the current directory or in the user's home directory (in
that order) and sources it into the user workspace."
Was "--no.init.file" given in the default startup? I cannot find a file
.Rprofile anywhere.
Same answer.
Back to Startup:
"It then loads a saved image of the user workspace from `.RData' if
there
is one (unless --no-restore-data was specified, or --no-restore)."
Since R opens with a saved workspace, I'd guess "--no-restore-data" was
not specified.
Same answer.
"Finally, if a function .First exists, it is executed as .First()."
I located such a function in a Rprofile file. It appears to load the
ctest package.
Yes, but you can put such an object earlier in the search path and so
override that one.
"The functions .First and .Last can be defined in the appropriate
startup
profiles or reside in `.RData'."
What or where are these appropriate startup profiles?
Rprofile.site, .Rprofile.
I located a
second Rprofile file in the \etc folder, but when I added a .First
function there it seemed to override the other .First function. Is that
intentional?
Yes. Most things in R are intentional!
Later in the Startup help:
"Lines in a site or user environment file should be either comment lines
starting with #, or lines of the form name=value. The latter sets the
environmental variable name to value, overriding an existing value. If
value is of the form ${foo-bar}, the value is that of the environmental
variable foo if that exists and is set to a non-empty value, otherwise
bar. This construction can be nested, so bar can be of the same form (as
in ${foo-${bar-blah}})."
Are environment files the same as profile files?
No, that's why the names are different (and the examples given are
different). An environment file is like .Renviron, and is described in
the Details section (as the help file says). A profile file contains R
code.
Finally, towards the bottom of the Startup help:
"Examples
## Some examples with a Unix flavour
# ~/.Renviron
R_LIBS=~/R/library
PAGER=/usr/local/bin/less
# .Rprofile
options(width=65, digits=5)
options(show.signif.stars=FALSE)
ps.options(horizontal=FALSE)
set.seed(1234)
.First <- function() cat("\n Welcome to R!\n\n")
.Last <- function() cat("\n Goodbye!\n\n")
## if .Renviron contains
FOOBAR="coo\bar"doh\ex"abc\"def'"
## then we get
cat(Sys.getenv("FOOBAR"), "\n")
coo\bardoh\exabc"def' "
What would some Windows examples look like?
.Rprofile the same.
.Renviron
R_LIBS=c:/R/library
I love R, and I would really like to learn something more about how it
is being customized for me and how I can (if I should) try to customize
it myself.
Some of this is in the rw-FAQ, including the use of .Renviron.
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._