1

When I installed a new version of R, my customised.Rprofile is not loaded. The R GUI starts using the new version and its corresponding .Rprofile.

Is there a way to still using the customised regardless of any update in the R version? A follow up question would be, can an R package load a different .Rprofile?

csgillespie
  • 59,189
  • 14
  • 150
  • 185
donpresente
  • 1,230
  • 2
  • 13
  • 24

1 Answers1

3

You should read the help page ?.Rprofile

To summarise:

  1. R first checks for a site-wide configuration file. To find that file, run

    (site_path = R.home(component = "home"))
    fname = file.path(site_path, "Rprofile.site")
    file.exists(fname)
    
  2. Then looks for .Rprofile in your current working directory - getwd()

    fname = file.path(getwd(), ".Rprofile")
    file.exists(fname)
    
  3. Then looks for an .Rprofile in your home area.

    file.exists("~/.Rprofile")
    

If you have an .Rprofile in you current working directory, R won't use the file in you home area.


Regarding your follow-up question. The .Rprofile is just an R file, so can be loaded via source and hence in a package. However, this is non-standard and should be avoided.

csgillespie
  • 59,189
  • 14
  • 150
  • 185