[R] R: Idea behind .First() vs. ~/.Rprofile
sarah.goslee at gmail.com
Fri Apr 17 22:25:01 CEST 2015
On Thursday, April 16, 2015, paul <paul.domaskis at gmail.com> wrote:
> I'm ramping up on R, and reading
> I'm probably wrong about this, but ~/.Rprofile seems to serve the same
> purpose as a .First() function. Why do both exist, and what
> considerations go into a decision to choose one over the other for
> startup code?
It's the timing and where the info comes from, as that document explains in
.Rprofile is read on start-up unless R is specifically told to skip it.
.First() is sourced after it's loaded, and thus must be loaded from
somewhere such as an existing .RData file or a package.
~/.Rprofile is thus most convenient for things you want to have happen in
every R session, while .First() is useful for specific sessions loaded from
saved objects, or for constructing packages. Though on linux, I use a local
.Rprofile if I need per-session options, because I often don't have a saved
[[alternative HTML version deleted]]
More information about the R-help