[R] R: Idea behind .First() vs. ~/.Rprofile

paul paul.domaskis at gmail.com
Fri Apr 17 22:32:04 CEST 2015


Sarah Goslee <sarah.goslee <at> gmail.com> writes:
|On Thursday, April 16, 2015, paul <paul.domaskis <at> gmail.com>
|wrote:
|> I'm ramping up on R, and reading
|> http://stuff.mit.edu/afs/sipb/project/r-
|> project/lib/R/library/base/html/Startup.html.  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 great detail.
|
| .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 .RData file.

Thanks, Sarah.  Yes, the documentation has a great deal of detail, but
I needed was your explanation in the final paragraph of your response.



More information about the R-help mailing list