Startup                 package:base                 R Documentation

_I_n_i_t_i_a_l_i_z_a_t_i_o_n _a_t _S_t_a_r_t _o_f _a_n _R _S_e_s_s_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     In R, the startup mechanism is as follows.  If a file `.Renviron',
     or a file pointed to by `R_ENVIRON' or `~/.Renviron', exists, it
     is processed to set environmental variables.  (This is suppressed
     by the flag `--no-environ'.)  See Details for how the file is
     read.

     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'. This code is loaded into package `base'.

     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.

     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').

     Finally, if a function `.First' exists, it is executed as
     `.First()'.

     The functions `.First' and `.Last' can be defined in the
     appropriate startup profiles or reside in `.RData'.

     The commands history is read from the file specified by the
     environment variable `R_HISTFILE' (default `.Rhistory') unless
     `--no-restore-history' was specified (or `--no-restore').

     The command-line flag `--vanilla' implies `--no-init-file',
     `--no-restore' and `--no-environ'.

_U_s_a_g_e:

     .First <- function() { ...... }

     .Rprofile <startup file>

_D_e_t_a_i_l_s:

     Lines in a `.Renviron' 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}}').

     Leading and trailing white space in `value' are stripped. No other
     interpretation of `value' is performed. In particular, if it is
     enclosed in quotes, the quotes form part of the value.

_N_o_t_e:

     Prior to R version 1.2.1, `.Rprofile' was sourced after `.RData'
     was loaded, although the documented order was as here.

     The format for `.Renviron' files was changed in version 1.2.0.
     Older files are quite likely to work but may generate warnings on
     startup if they contained unnecessary `export' statements.

_S_e_e _A_l_s_o:

     `.Last' for final actions before termination.

