What happens when R starts?
19 What happens when R starts?
When
R loads itself it parses some start up files that allow the
user to store user changes to the environment and frequently used
commands. The documentation for these files is accessed with the
command
help(Startup).
In particular, the user may store frequently used commands in a file
called
.RProfile. This file is searched for in the current
directory and if not found the users home directory. This file should
contain
R code. There are special functions though. If the
functions
.First or
.Last are found, they are executed
as the first (or last) thing done in an
R session. As a simple
example, if the
.RProfile file was
.First <- function() print("Hola")
.Last <- function() print("Hasta La Vista")
Then when starting
R and quitting your screen might look something
like
R is free software and comes with ABSOLUTELY NO WARRANTY.
...
[Previously saved workspace restored]
[1] "Hola"
> q()
Save workspace image? [y/n/c]: n
[1] "Hasta La Vista"
Process R:2 finished...
More useful things for this file are of course quite possible.
Copyright © John Verzani, 2001-2. All rights reserved.