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
?
You should read the help page ?.Rprofile
To summarise:
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)
Then looks for .Rprofile
in your current working directory - getwd()
fname = file.path(getwd(), ".Rprofile")
file.exists(fname)
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.