How to change .Rprofile location in RStudio

I am working with the "factory new" version of RStudio on Windows 7. R is installed under C:/Program Files, which means that the default libraries are stored here, and the two locations contained in .libPaths()at startup are both in this folder.

I want to work with another R library (igraph). Since the folder C:\Program Filesis write-protected, I created another area for work: C:\Users\nick\Rand installed the igraph library in C:\Users\nick\R\library. I can manually add this location to a variable .libPaths()and use the library without any problems.

However, my problem is that RStudio automatically adds this location to the variable .libPaths()at startup. I read that I can add the appropriate command to the .Rprofile file, but I could not find such a file (presumably, they are not created automatically when RStudio is installed). Then I created a file called .Rprofile containing only this command. This seemed to work when the .Rprofile file was saved in C:\Users\nick\Documents(this is the path that is stored in both the R_USER environment variables and in HOME). I would like to have a .Rprofile file stored in C:\Users\nick\R.

I read all the information in "Startup" and talks about where to store the commands that run at startup. But I just can't do this job. For example, there seems to be no way to change the location of the home directory without reading the file stored in the home directory. It seems I don't have any .Renviron files and creating them doesn't seem to work either.

I would really appreciate the answer in simple terms explaining how I can change where the .Rprofile file is read.

+5
source share
1 answer

On Windows, you set the R_USER profile by opening a command prompt and starting:

SETX R_PROFILE_USER "C:/.../.Rprofile"

Where (obviously) the path is the path to your desired .Rpofile. In R, you can verify that this worked:

Sys.getenv("R_PROFILE_USER")

. , R_USER , , R.

+1

All Articles