25

New to R. How does one access and edit Rprofile?

pppery
  • 3,731
  • 22
  • 33
  • 46
Aitch
  • 297
  • 1
  • 3
  • 10
  • 1
    Take a look at this description from [Quick R](https://www.statmethods.net/interface/customizing.html) – G5W Oct 18 '17 at 21:57
  • Thanks. I googled edit Rprofile in the past but I hadn't clicked through on link called 'customizing StartUp File' https://www.statmethods.net/interface/customizing.html and on your prompting I did and found it helpful. – Aitch Oct 18 '17 at 22:46
  • 1
    Rprofile file is found in C:\Program Files\R\R-3.4.1\etc and can be edited by loading it into Notepad++. – Aitch Oct 18 '17 at 22:55

1 Answers1

65

On start-up R will look for the R-Profile in the following places: (https://csgillespie.github.io/efficientR/set-up.html)

  1. R_HOME: the directory in which R is installed. Find out where your R_HOME is with the R.home() command.
  2. HOME, the user’s home directory. Can ask R where this is with, path.expand("~")
  3. R’s current working directory. This is reported by getwd().

Note although there maybe different R-Profile files R will only use one in a given session. The preference order is:

Current project>Home>R_Home

To create a project-specific start-up script create a .Rprofile file in the project’s root directory.

You can access and edit the different .Rprofile files via

file.edit(file.path("~", ".Rprofile")) # edit .Rprofile in HOME
file.edit(".Rprofile") # edit project specific .Rprofile    

There is information about the options you can set via

help("Rprofile")

As mentioned the link above does provide additional details but the points outlined above should show you where the files are and how to access them.

Julien
  • 1,613
  • 1
  • 10
  • 26
mmarks
  • 1,119
  • 7
  • 14