Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Setting the default R working directory on startup


View products that this article applies to.

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"
   setwd(rCodeDir)
   source("C:/MyRdir/startup.R")
   cat("\nWelcome at", date(), "\n")



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

library(nws)
library(KernSmooth)

 

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:

      C:\Revolution\R-Enterprise-7.0\IDE64\RevoIDE.exe


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

      C:\MyRdir


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.

↑ Back to the top


Keywords: kb

↑ Back to the top

Article Info
Article ID : 3103291
Revision : 1
Created on : 1/7/2017
Published on : 10/26/2015
Exists online : False
Views : 68