[R] autoloading .RData files / .Rhistory file

Greg Tarpinian sasprog474474 at yahoo.com
Thu Mar 16 19:23:47 CET 2006

     NOTE: WinXP, R2.2.0


a while back I posted a question about using relative filereferencing.
The responses have allowed me to successfully set up the following
directory structure:


In the \prog directory I have put an RGui.exe shortcut and "pointed it"
at \prog as the "Start In" location.  In the same directory I have
created .Rprofile and .Renviron per the rw-FAQ.  In \log I have created
.Rhistory.  .Renviron sets up several directory references that allow me
to "point" R at the \lst, \log, \data\derived, and \data\raw directories
without using full pathnames.  My three questions:

  (1) Is it possible to have R use \data\derived as its default data
      storage location?

  (2) Related to (1), what command(s) would I need to put in .Rprofile 
      to get R to look in \data\derived and automatically load the 
      xxx.RData file **when it exists** ?? [This is the only directory 
      where an .RData file will ever be located; when an .RData file 
      exists, there will only ever be one of them.]
      Along these lines, it would be helpful to set R up so that when
      .RData does *not* exist, upon quitting Rgui.exe R will automatically
      save an xxx.RData file in the \data\derived directory.....

  (3) The .Rhistory file never seems to contain the command history of
      my session.  It may be worthwhile to note that I always use an 
      explicit save.image(file = ...) command and that upon exit I always
      decline to "Save Workspace Image?" since this is redundant.  How
      can I get the .Rhistory file to capture the command history?

Much thanks in advance for whatever help I might be able to obtain!  I
apologize if these are trivial questions.

Kind regards,


More information about the R-help mailing list