Setting the default R working directory on startup

Automatically setting the default working directory is a bit different in Revolution R than it is in CRAN-R. Because the Revolution IDE has its own startup and initialization sequence, you need to set any R commands you want to use in a .First function that is called in a local .Rprofile on startup.

The contents of this .First function might look as follows:

User-specific .Rprofile:

.First <- function(){
   rCodeDir <<- "C:/MyRdir"
   cat("\nWelcome at", date(), "\n")

Here the file 'startup.R' is a further R script that contains the following commands:



The steps to create this kind of configuration are the following:

1). Using 'Notepad' or your favorite editor, create a file named .Rprofile with the above content.
    (Note that this file begins with a 'period' in the name and DOES NOT have a file extension)
    If you are using Notepad choose 'File ---> Save As'. As the 'File Type' select 'All Files'(*.*).
    Do not save the file with a (*.txt) file extension).

   Save this file into the directory 'C:\MyRdir'.

   Also save the file 'startup.R' with the above contents in this same folder.

2).  Launch Revolution R Enterprise. After opening the program, goto 'Tools ---> Options ---> Revolution RPE Options --> Load last solution at startup'
      and verify that it is set to 'False'. Change it if it is set to 'True'.
      Also verify that the option 'Automatically run .Rprofile' is set to 'True'. Change it if it is set to 'False'.

3).  Create a Windows icon shortcut on your desktop to:


4).  Create a directory on your computer that contains the .Rprofile file, let's say:


5).  Edit the properties of the Windows icon shortcut. Change the 'Start in:' field of the shortcut
     so it says:   C:\MyRdir

     Click 'Apply' and 'OK' to change the shortcut settings.

6). Double-click the shortcut to launch Revolution R Enterprise in the future.
     All your startup settings should be applied and the default working directory should now be changed.

Article ID: 3103291 - Last Review: 26 Oct 2015 - Revision: 1