Message-ID: <CAM_vjum9_EjaCtPNcdcLHtiny+jpL4TE5cJBCPpz395WVRHsOg@mail.gmail.com>
Date: 2015-04-17T20:25:01Z
From: Sarah Goslee
Subject: R: Idea behind .First() vs. ~/.Rprofile
In-Reply-To: <loom.20150416T212859-247@post.gmane.org>
Hi,
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.
Sarah
--
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org
[[alternative HTML version deleted]]